Skip to content

Instantly share code, notes, and snippets.

@since1976
Last active December 20, 2015 10:39
Show Gist options
  • Save since1976/6117417 to your computer and use it in GitHub Desktop.
Save since1976/6117417 to your computer and use it in GitHub Desktop.
Terminal command to batch rename files.
// 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