“Send To” in Linux for Nautilus


It’s been a common practice among the windows users to right click and search for “Send To” option when a file needs to copied to the USB or any other Drive.
Why spare me, even i used to do this while using windows, when to my astonishment i found that there exists no such option in the default window (“Nautilus”) in Ubuntu. So i thought of making one for my convenience.
Nautilus supports user scripts inside it. This can be easily embedded into the manager by inserting it into the folder ~/.gnome2/nautilus-scripts/ folder where ~ stands for the shortcut for home folder.
I used zenity ( a in build gnome dialog box) to get the radio box for selecting the drive to copy to.
The Send to function looks like this



The Code :

#!/bin/bash
destination='Choose Destination'
title_destination='Send files to:'

copy='Copying'
title_copy='Please wait...'

success='Files successfully copied'
title_success='Success'

errors='Something went wrong'
title_errors='Error'

no_writable='Destination is either not existant or writable'
title_no_writable='Error'
vd=$(ls -tm /media/sed 's/cdrom[0-9]?[,]?[ ]?//g')
#options=${vd//, / FALSE /media/}
IFS=$'tn'
options=$(echo $vdsed 's_[ ]?([^,]*),_/media/1tFALSEt_g'sed 's_(.*)tFALSEt_1_g');
destinazione=$(zenity --list --title "$title_destination" --text "$destination" --radiolist --column " " --column "Device" TRUE $options);

if [[ "$destinazione" = "" ]]; then
exit
fi

if [[ -w $destinazione ]]; then
NAUTILUS_SCRIPT_SELECTED_FILE_PATHS=$(echo $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS)
destinazione=$(echo $destinazione)
cp -R "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" "$destinazione"  zenity --progress --pulsate --auto-close --title="$title_copy" --text="$copy"
if (( $? == 0 )); then
zenity --info --text="$success" --title "$title_success";
else zenity --info --text="$errors" --title "$title_errors";
fi
else zenity --info --text="$no_writable" --title "$title_no_writable";
fi

, , , , ,

  1. No comments yet.
(will not be published)