Skip to content

Instantly share code, notes, and snippets.

@betacar
Last active Aug 29, 2015
Embed
What would you like to do?
Converts all subtitles files of a folder from ISO-8859-1 encoding to UTF-8
#!/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