Skip to content

Instantly share code, notes, and snippets.

@sae13
Last active September 22, 2019 04:19
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sae13/71e3e18f6ac14248be1acd5f498334a6 to your computer and use it in GitHub Desktop.
Save sae13/71e3e18f6ac14248be1acd5f498334a6 to your computer and use it in GitHub Desktop.
Fix Subtitle encoding to UTF-8
#!/bin/bash
fullPATH=$1
echo $fullPATH >/tmp/subtitleFIX.log
encode=`file -ib $fullPATH|cut -d= -f 2`
echo "encode is : "$encode >>/tmp/subtitleFIX.log
if [ "$encode" == 'unknown-8bit' ];then
encode="WINDOWS-1256"
elif [ "$encode" == "utf-8" ];then
notify-send "فایل مشکلی نداره"
exit
fi
fromFILE=$fullPATH
fromFILEwithNOextention=`echo $fromFILE|cut -d. -f -1`
backupFILE=`echo $fromFILEwithNOextention".bak.srt"`
mv $fromFILE $backupFILE
iconv $backupFILE -f $encode -t UTF-8 > $fromFILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment