Created
August 22, 2018 17:02
-
-
Save CloverFeywilde/6c97b3e5ef3d9033ff7bc7b2e0c3b54b to your computer and use it in GitHub Desktop.
Batch Remove or Replace characters from file names
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
#For use with a set of sequential files that contain extra zeroes. ex: file001.jpg, file002.jpg, file003.jpg ect. | |
#Replace <firstPartOfName> with everything up until the bit you want to remove. No brackets. | |
#replace <removeThis> with what you need removed, <replaceWithThis> for what you want in its place. | |
#You can leave <replaceWithThis> blank if you simply want to remove. | |
for file in <firstPartOfName>*; do | |
new_name=$(echo "$file" | sed -E -e 's/<removeThis>+/<replaceWithThis>/') | |
mv "$file" "$new_name" | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment