Last active
March 27, 2021 11:58
-
-
Save itshaadi/594db4536ef412bf16bc5eec6607279a to your computer and use it in GitHub Desktop.
this script will change the encoding from whatever to UTF-8
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 | |
#you may need to install uchardet package first. sudo apt install uchardet | |
# https://github.com/BYVoid/uchardet | |
#replace underscore with white-space !important (iconv cannot find files with white-space in their name) | |
find -name "* *.srt" -type f | rename 's/ /_/g' | |
for sub in *.srt; | |
do | |
encode="$(uchardet "${sub}")" | |
if [ "$encode" == "x-mac-cyrillic" ] | |
then encode="WINDOWS-1256" | |
fi | |
iconv -f "${encode}" -t UTF-8 "${sub}" -o "${sub}.tmp" && mv -f "${sub}.tmp" "${sub}" && echo "${sub} - *fixed*" | |
done | |
echo "done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment