Created
December 2, 2014 20:45
-
-
Save pleasetrythisathome/1a98e329a08cd0fd47bb to your computer and use it in GitHub Desktop.
bash clean filenames
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
# convert all spaces to underscores, remove characters like {}(),\! and convert the filename to lowercase. | |
ls | while read -r FILE | |
do | |
mv -v "$FILE" `echo $FILE | tr ' ' '_' | tr -d '[{}(),\!]' | tr -d "\'" | tr '[A-Z]' '[a-z]' | sed 's/_-_/_/g'` | |
done | |
# just spaces to underscores | |
ls | while read -r FILE | |
do | |
mv -v "$FILE" `echo $FILE | tr ' ' '_' ` | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment