Created
February 12, 2013 03:23
-
-
Save sweetmandm/4760006 to your computer and use it in GitHub Desktop.
Just a simple bash script to batch rename files: takes one or two strings as arguments, and removes or replaces all instances of that string from within all filenames in the specified directory.
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 | |
# | |
# Replaces a string from all filenames in the sourcedir. | |
# If the second argument is empty, it will simply remove the string. | |
sourcedir="." | |
stringToChange="$1" | |
replacementString="$2" | |
cd "$sourcedir" | |
for f in *"$1"*; do | |
mv "$f" "${f/$stringToChange/$replacementString}"; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment