Last active
September 22, 2019 04:19
-
-
Save sae13/71e3e18f6ac14248be1acd5f498334a6 to your computer and use it in GitHub Desktop.
Fix Subtitle 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 | |
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