Created
January 14, 2015 19:04
-
-
Save kadin2048/5aa29d0691f3b4400863 to your computer and use it in GitHub Desktop.
Renames files that have the same basename but different extensions, e.g. 'somefile.avi', 'somefile.nfo', 'somefile.txt' to 'anotherfile.avi', 'anotherfile.nfo', etc.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# From http://stackoverflow.com/questions/15585441/batch-renaming-multiple-files-with-different-extensions-linux-script | |
# first argument - basename of files to be moved | |
# second arguments - basename of destination files | |
if [ $# -ne 2 ]; then | |
echo "Two arguments required." | |
exit; | |
fi | |
#echo "First argument $1" | |
#echo "Second argument $2" | |
for i in "$1".*; do | |
if [ -e "$i" ]; then | |
mv "$i" "$2.${i##*.}" | |
echo "$i to $2.${i##*.}"; | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment