Last active
August 29, 2015 14:00
-
-
Save betacar/11187280 to your computer and use it in GitHub Desktop.
Converts all subtitles files of a folder from ISO-8859-1 encoding to UTF-8
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 | |
for file in ./*.srt | |
do | |
encoding=`file --mime-encoding "$file" | awk '{ print $2 }'` | |
if [ $encoding = "iso-8859-1" ] | |
then | |
iconv -f iso-8859-1 -t utf-8 < "$file" > "$file.utf8" | |
mv "$file.utf8" "$file" | |
echo "$file converted to UTF-8" | |
else | |
echo "$file is not ISO-8859-1 encoded" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment