Created
March 29, 2015 20:02
-
-
Save raym/cdadeecf6a0245cd23da to your computer and use it in GitHub Desktop.
mv all files in a directory with a particular extension -- remove dashes, underscores, spaces, dots (add more if you like) and lowercase the filename
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/bash | |
ext=.png | |
for file in *$ext; do | |
baseName=${file%$ext} | |
baseNoDashes=$(echo $baseName | tr -d '_- .') | |
baseLower=$(echo $baseNoDashes | tr '[:upper:]' '[:lower:]') | |
fileNew=$baseLower$ext | |
echo Renaming $file to $fileNew | |
#mv $file $fileNew #uncomment to actually do it | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks!!