Skip to content

Instantly share code, notes, and snippets.

@elundmark
Created December 24, 2011 17:46
Show Gist options
  • Save elundmark/1517925 to your computer and use it in GitHub Desktop.
Save elundmark/1517925 to your computer and use it in GitHub Desktop.
Robust Copy to... script for Nautilus
#!/bin/bash
dropbox=$(zenity --file-selection --directory)
filelog=""
for arg
do
if [ ! -f "${dropbox}/${arg}" ] && [ ! -d "${dropbox}/${arg}" ]
then
if [ -d "~/.local/share/Trash/files" ]; then
cp "${PWD}/${arg}" "${dropbox}/${arg}" &&\
mv -n "${PWD}/${arg}" ~/.local/share/Trash/files
else
cp "${PWD}/${arg}" "${dropbox}/${arg}"
fi
sleep 1
if [ -f "${dropbox}/${arg}" ] || [ -d "${dropbox}/${arg}" ]
then
filelog="${filelog} '${arg}'"
else
notify-send -i error "Copy to..." "Something went wrong!"
fi
else
notify-send -i error "Copy to..." "'${dropbox}/${arg}' already exists!"
fi
done
filelog=${filelog:1}
notify-send -i info "Copy to..." "${filelog} was copied to' ${dropbox}'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment