Skip to content

Instantly share code, notes, and snippets.

@jpbassalot
Created July 2, 2014 15:38
Show Gist options
  • Save jpbassalot/a0da0785d3c7b3a0f59d to your computer and use it in GitHub Desktop.
Save jpbassalot/a0da0785d3c7b3a0f59d to your computer and use it in GitHub Desktop.
Batch rename files with different extensions
#!/bin/sh
# first argument - basename of files to be moved
# second arguments - basename of destination files
if [ $# -ne 2 ]; then
echo "Two arguments required."
exit;
fi
for i in $1.*; do
if [ -e "$i" ]; then
mv "$i" "$2.${i##*.}"
echo "$i to $2.${i##*.}";
fi
done
# Reference: http://stackoverflow.com/questions/15585441/batch-renaming-multiple-files-with-different-extensions-linux-script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment