Skip to content

Instantly share code, notes, and snippets.

@aont
Created March 10, 2011 13:40
Show Gist options
  • Select an option

  • Save aont/864102 to your computer and use it in GitHub Desktop.

Select an option

Save aont/864102 to your computer and use it in GitHub Desktop.
#!/bin/sh
if [ -d ~/.Trash ]; then
:
else
mkdir ~/.Trash
fi
for f in "$@"
do
basename=`basename $f`
extname=`echo $basename|sed -e "s/\([^.]*\)\(.*\)$/\2/"`
basename=~/.Trash/`echo $basename|sed -e "s/\([^.]*\)\(.*\)$/\1/"`
num=0
while [ -e ${basename}_${num}${extname} ]
do
num=`expr $num + 1`
done
mv -f $f ${basename}_${num}${extname}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment