Created
January 29, 2018 18:25
-
-
Save hlorand/115a4165df76ba6cd9f8b53179895029 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| ###################################### | |
| # REMOVES HUNGARIAN LETTER ACCENTS FROM FILENAMES IN CURRENT FOLDER | |
| # Works with OSX special character representation | |
| # ( https://stackoverflow.com/questions/6153345/different-utf8-encoding-in-filenames-os-x ) | |
| # Usage: | |
| # chmod +x removeaccents.sh | |
| # ./removeaccents.sh | |
| ######################################## | |
| printf "Renaming files:\n" | |
| for file in ./*; do | |
| if [ -f "$file" ] | |
| then | |
| FILENAME=$(basename "$file") | |
| CLEANFILENAME=$(echo "$FILENAME" | tr "áéíóöőúüűáéíóöőúüű" "a\'e\'i\'o\'o\"o\"u\'u\"u\"aeiooouuu" | sed 's/[^a-zA-Z0-9 \(\)_.-]//g' ) | |
| if [ "$FILENAME" != "$CLEANFILENAME" ] | |
| then | |
| printf "%s > " "$FILENAME" | |
| printf "%s\n" "$CLEANFILENAME" | |
| mv ./"$FILENAME" ./"$CLEANFILENAME" | |
| fi | |
| fi | |
| done | |
| printf "done\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment