-   Linux - Newbie (
-   -   Addin to Nautilus right click menu (

paddyjoy 03-07-2006 12:09 AM

Addin to Nautilus right click menu
I have a script that I use for resizing a jpg and uploading it using ftp onto my webserver. Is there some way I can add this script to the nautilus right click menu so that I can just right click on a jpg(or multiple jpg's) and select upload and the script will do the rest?


zeitounator 03-07-2006 10:22 AM

Put that script in your nautilus-script folder (~/.gnome2/nautilus-scripts). It will then be accessible through right-click > script > scriptName.

You'll probably need to modify your script a little bit as nautilus scripts expect to read their arguments from an environment variable. As a starter example, here is a script I use for rotating jpeg files. For more info, has some valuable scripts and tips.


# Nautilus script to rotate jpeg images.
# Put that script
# in your ~/.gnome2/nautilus-script folder. You can then use
# it from any folder after selecting the images your want to
# rotate with "right-click > scripts > rotateJpeg"
# Copyright 2005 Olivier Clavel
# Author: Olivier Clavel <contact AT retiz DOT com>
# Licence: GPL (
# Depends: nautilus, libjpeg (jpegtran), gnome-utils (zenity), file

# We set input field separator to "new line" so that we can safely read
# file name with spaces from $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS
# location of temporary directory for file rotation
TMPDIR="/tmp"                    # Temporary directory

# Test if a file has been selected
if [ $# -eq 0 ]; then
        zenity --error --title="error" --text="You must select at least 1 file to process"
        exit 1

# Ask for desired clockwise rotation.
rotation=`zenity --title "JPEG rotation" --list --column "" --radiolist --column "Clockwise rotation in degrees" TRUE 90 FALSE 180 FALSE 270`

# If no rotation value was selected, user clicked cancel: exit
if [ -z "$rotation" ] ; then

# Go for rotation
  # check if the file is jpeg
  isJpeg=`file -bi "$name" | grep jpeg | wc -l`
  if [ $isJpeg -eq 1 ] ; then
      # Rotate the picture in a temporary file.
      jpegtran -copy all -rotate $rotation "$name" > $TMPDIR/tmppict.jpeg
      # Replace the original file with the rotated one.
      mv $TMPDIR/tmppict.jpeg "$name"
  let "processedFiles++"
  let "progress=processedFiles*100/totalFiles"
  echo $progress
done) |
zenity --progress --auto-close --title="Images Rotation"  --text="Processing images ..."  --percentage=0

Good luck

paddyjoy 03-07-2006 05:01 PM

Thanks for the info! Before your post I actually discovered nautilus-actions. I think it is probably just a gui for putting scripts in the ~/.gnome2/nautilus-scripts directory!

Do you know what user the scripts run as? Is it the user who is logged in?

I have a script that resizes and uplaods pictures to a web server. It works perfectly when I run it from the command line but doesn't work through the menu, any idea where the error messages go? Can't find them in /var/log/messages.

Sorry for all the question!

Here is my script, it resizes the files ok but then when it tries to execute ./ it fails.



for FILE in $*
        convert $FILE -resize 384x $FILE

./ $*
if [ $OUT -eq 0 ];then
        zenity --info --info-text "Files Uploaded!"
        zenity --info --info-text "Failed for some reason!"

zeitounator 03-07-2006 08:45 PM

Change ./ to an absolute path. I guess that is your problem.

For the other questions: yes, the script run as the loged in user. Those script are in a personal directory anyway in your home and are not shared with other users.

About standard output and error, that's the bad part: it does not go anywhere (at least nowhere I could find). I've found this messageadvising to run nautilus from a command line to get standard output and error in the same terminal. Unfortunately it does not work for me (nautilus launches a new window and exits).

paddyjoy 03-07-2006 08:57 PM

Thanks I can't believe I missed that, it was late last night when I was playing with this ha ha!

It's a pity that you can't catch the output/error, it would greatly enhance this software. In my case if I had got a "file not found ./" message it would have made solving my problem a lot easier!


zeitounator 03-08-2006 08:26 AM


Originally Posted by paddyjoy
Thanks I can't believe I missed that

I often need a second pair of eyes as well :)

All times are GMT -5. The time now is 05:26 AM.