Created
July 26, 2011 15:07
-
-
Save peta/1106968 to your computer and use it in GitHub Desktop.
weirdo-char-stripper
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
#!/usr/bin/env bash | |
if [ $(($#)) -gt 0 ]; then | |
cwd=$1 | |
else | |
cwd=`pwd` | |
fi | |
cd "$cwd" | |
for folder in * | |
do | |
new_folder=${folder//[^a-zA-Z0-9 .\-_]/} | |
if ! [ -e "$new_folder" ]; then | |
echo "Renaming '$folder' to '$new_folder'" | |
mv "$folder" "$new_folder" | |
else | |
echo "Skipping '$folder'" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment