- About Us
A Nautilus Script is an executable file, written in a scripting language, which can perform some function on files or folders selected from within the Nautilus file manager window.
Linux is rich with scripting languages, including Python, Perl, and Ruby, and has a variety of command line shells to choose from, such as Bash, Zsh, and Csh. Any of these can be used to write a Nautilus Script.
You don't need to know how to write Nautilus Scripts to use them. A search on the Web for Nautilus Scripts will return a number of links to scripts other people have already written and have made available for others to use. G-Scripts is a site that gathers many of these scripts.
Scripts are usually packaged in compressed archives, so, once you've downloaded a script you're interested in, you'll need to extract it using an archiving program such as File Roller for GNOME, or Ark for KDE.
Next, you need to copy the file to the .gnome2/nautilus-scripts folder inside your home folder. The dot in front of the folder name means it is a hidden folder, so you will need to make sure you can see it in Nautilus by selecting Show Hidden Files from the View menu.
Finally, you need to make the script executable. View the properties of the file in Nautilus and, on the Permissions tab, check the Execute checkbox for the owner of the file -- that should be you.
If you prefer to use the command line, open a terminal and navigate to the folder where you downloaded your script, then unpack it with one of the following commands, depending on the file extension of the file you wish to decompress:
tar -zxvf myscript.tgz
tar -zxvf myscript.tar.gz
tar -jxvf myscript.bz2
Copy the script to the nautilus-scripts folder:
cp myscript ~/.gnome2/nautilus-scripts
Change the script's permissions so that it is executable:
chmod u+x myscript
If you want all users on your system to be able to use the script, it should be installed into the /usr/share/nautilus-scripts folder. You'll need to have superuser privileges to copy the script into this folder and change its file permissions.
How do you use a script? From within Nautilus, navigate to a file and select it. Then click it with your right mouse button, and a context menu will appear with a Scripts menu item. You can also open the Scripts menu item from the File menu and, if you are using Nautilus to manage your Desktop, from a right mouse click on the Desktop. This menu item is not visible if no Nautilus Scripts are installed. Expand the Scripts menu item and you should see your script listed. Click it, and the script will perform its actions on the file you have selected. Many scripts allow you to select multiple files at once.
If you're looking for ready-made scripts, see the G-Scripts site. G-Scripts has scripts for archiving files, opening files with particular applications, sending files via email, image manipulation, integration with the Subversion version control system, and package management, to name just a few.
Writing a Nautilus Script
To write a Nautilus Script, you'll need to know at least the basics of your chosen scripting language. A good starting point is to look at how others have written their Nautilus Scripts and get ideas from them.
If you are using an external program in your script, you will also need to find out which command line parameters it accepts. In your script, construct the parameters your external program needs, then call the program, passing it those parameters.
Let's take a look at a simple script, which creates a new email message using the Sylpheed-Claws email client, and includes the files you select in Nautilus as attachments.Next: A sample script