Nautilus scripts allow you to preform many tasks just by right clicking and selecting to run a script, scripts can be very handy if you don't want to have to got to the terminal and type in all this obscure stuff to convert a file in ffmpeg, you could just write it once in a script then never have to write it again.
below i am going to show you how to write a script for use in nautilus.
Ok, so a script to chmod 777 any file/folder you run this script on
first we start by opening a text editor vi/emacs/gedit
Whenever writing a bash script (a script using bash (terminal) commands)
we start the file like
this tells the computer what language your script is in.
now the main difficulty (well only real difficulty) in writing simple bash scripts is how do we tell the computer to act upon the file we are clicking on.
$@ is the answer. or i believe $? can be used as well (but im not sure)
so if we were to chmod a file called blah in our home directory we would use
but now we have another problem -- if i upload my scripts they wont work for other people because they may not have a user called bod. so we need to find a way of getting the users name before the script does its buissness.
sudo chmod 777 /home/bod/blah
now we could use '~' but i prefer to use variables
will print the username if run in a terminal.
so we use this code to store the output of 'whoami' into avariable
now for those of you with little or no bash/programming knowledge
that piece of code basically has added the output of 'whoami' into the variable $userName so when we type $userName the script will substitute it for the contents of the variable.
so are script should now look like this
now we can add the chmod stuff
now this will work but with 1 problem, when you use it first time its fine but the second time wont work because sudo/gksudo has a 5/10/15 (cant remember which) timer on it so will not show up aainduring that period, so we needto reset the time before we run the gksudo
gksudo chmod 777 ./$@
the command to reset the timer is sudo -k
so when we add this to the script it should look like
Thats it thats your first nautilus script,now save it to
gksudo chmod 777 ./$@
then got to terminal and type
then give your script a try
sudo chmod 777 /home/'user'/.gnome2/nautilus-scripts/*
You can make a script do almost anything -- just remember the $@ and you will be overwhelmed in scripts in no time
Hope this helped