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.
You need php. Try typing php on the terminal to find it it’s installed. If not, you can get it typing sudo apt-get install php5-cli
To create the script, open the gedit Text Editor and paste the following code:
- Go to File > Save As… and enter this as the file name: ~/.gnome2/nautilus-scripts/webloc_convert
- In the terminal, type chmod u+x ~/.gnome2/nautilus-scripts/webloc_convert to make the script executable, so it shows on right click.
- Now you can test it! Right click a .webloc file, go to Scripts > webloc_convert, and the file suddenly should show up as a valid .desktop file (the extension is probably invisible). If the Scripts submenu is not visible you might have to log out from Ubuntu and log in again.
- NOTE: use at your own risk! If you don’t like the fact that the original file gets deleted, edit the script and delete the line 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.