Skip to content

Instantly share code, notes, and snippets.

@geoffrepoli
Last active February 22, 2018 22:56
Show Gist options
  • Save geoffrepoli/7a262cde2830f468d72f207f02cd00fa to your computer and use it in GitHub Desktop.
Save geoffrepoli/7a262cde2830f468d72f207f02cd00fa to your computer and use it in GitHub Desktop.
while IFS= read -r f; do
file=${f##*/}
if [ -f $dest/$file ]; then
n=1
while [ -f $dest/${file%%.*}-$n.${file##*.} ]
do (( n++ ))
done
file=${file%%.*}-$n.${file##*.}
fi
mv $f $dest/$file
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment