-
-
Save mPastuszko/f521835cadd376c9d4f1 to your computer and use it in GitHub Desktop.
Correct weird encoding of Polish special characters in filenames recursively in the current directory
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 | |
replacements=\ | |
"-e s/ą/ą/g "\ | |
"-e s/ć/ć/g "\ | |
"-e s/ę/ę/g "\ | |
"-e s/ń/ń/g "\ | |
"-e s/ś/ś/g "\ | |
"-e s/ó/ó/g "\ | |
"-e s/ź/ź/g "\ | |
"-e s/ż/ż/g " | |
for file in `find . -type f`; do | |
correct_fn=$(echo "$file" | sed $replacements) | |
mv "$file" "$correct_fn" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It lacks support for whitespace in filenames. This fixes that (includes develth's "fix" as well). I added verbose (-v) to mv, feel free to remove it. Many thanks for the original idea.