aBe PaZoS SoLaTie

Ubuntu (Nautilus) script to convert .webloc files

Fri Jun 4, 2010


A few days ago I bought a new laptop. I installed Ubuntu 10.04, and now I’m migrating my files from my iMac to this laptop. I had some .webloc files which Ubuntu didn’t understand, so I wrote a small script that I can run just doing a right click on the .webloc file to convert it to a valid Nautilus url-link file. I do plan to learn Python, but I used PHP since that’s what I know. You are welcome to port it to any other language.

URL\<\/key\>.*?\(.*?)\<\/string\>/mis', $fileContent, $foundA); $NAME = basename($filePath, '.webloc'); $URL = $foundA[1]; $NEWPATH = str_replace('.webloc', '.desktop', $filePath); $fp = fopen($NEWPATH, 'w'); fputs($fp, "[Desktop Entry]\n". "Encoding=UTF-8\n". "Name=$NAME\n". "Type=Link\n". "URL=$URL\n". "Icon=gnome-fs-bookmark"                     ); fclose($fp); // Delete old file. I tried using the Trash but didn't work unlink($filePath); } } ?>

I really like the idea of the Nautilus scripts folder. You can use any programming language you are comfortable with to process files and folders with a simple right click on the standard file manager. This gives me so much freedom to add small features that save me time, without going down to learning C and compiling programs. Find out more about Nautilus scripts.