Skip to content

Instantly share code, notes, and snippets.

@hlorand
Created January 29, 2018 18:25
Show Gist options
  • Select an option

  • Save hlorand/115a4165df76ba6cd9f8b53179895029 to your computer and use it in GitHub Desktop.

Select an option

Save hlorand/115a4165df76ba6cd9f8b53179895029 to your computer and use it in GitHub Desktop.
#!/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