A worked example of a Nautilus script that works with spaces in filenames.

Drop the attached script into ~/.gnome2/nautilus-scripts, and make it 
executable.
In Nautilus, select a number of files that contain spaces in their filenames.
Right-click, Scripts, Show Nautilus Parameters



=======================================================================
This email, including any attachments, is only for the intended
addressee.  It is subject to copyright, is confidential and may be
the subject of legal or other privilege, none of which is waived or
lost by reason of this transmission.
If the receiver is not the intended addressee, please accept our
apologies, notify us by return, delete all copies and perform no
other act on the email.
Unfortunately, we cannot warrant that the email has not been
altered or corrupted during transmission.
=======================================================================

#!/bin/bash

(
   echo "\$* = $*"
   echo "NAUTILUS_SCRIPT_SELECTED_FILE_PATHS = 
$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS"
   echo "NAUTILUS_SCRIPT_CURRENT_URI = $NAUTILUS_SCRIPT_CURRENT_URI"
   echo "PWD = $PWD"

   # Magic incantation to make Nautilus scripts work with spaces in filenames:
   echo -n "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" | while read file ; do
      ls -l "$file"
   done

) | /usr/bin/zenity --text-info

=======================================================================
This email, including any attachments, is only for the intended
addressee.  It is subject to copyright, is confidential and may be
the subject of legal or other privilege, none of which is waived or
lost by reason of this transmission.
If the receiver is not the intended addressee, please accept our
apologies, notify us by return, delete all copies and perform no
other act on the email.
Unfortunately, we cannot warrant that the email has not been
 altered or corrupted during transmission.
=======================================================================

Reply via email to