Last active
December 20, 2015 10:39
-
-
Save since1976/6117417 to your computer and use it in GitHub Desktop.
Terminal command to batch rename files.
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
// To view what files will change to run | |
for file in *; do mv echo "$file" "${file/part of the file you want removed/}"; done | |
// To actually run the command | |
for file in *; do mv "$file" "${file/part of the file you want removed/}"; done | |
// This will cut everything before the first dot and appends .mov | |
for i in *; | |
do j=`echo $i | cut -d . -f 1`; | |
j=$j".mov"; | |
mv $i $j; | |
done | |
// This will cut everything before the first hyphen and appends .jpg | |
for i in *; | |
do j=`echo $i | cut -d - -f 1`; | |
j=$j".jpg"; | |
mv $i $j; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment