Created
February 3, 2009 13:49
-
-
Save shapeshed/57526 to your computer and use it in GitHub Desktop.
Bash script to convert all filename in a folder to lowercase and replace spaces with underscores
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 | |
# Replaces spaces in filenames with underscores and converts filenames to lowercase | |
# Run within a directory to convert all files | |
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 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment