Advertisement
Guest User

subfix.sh

a guest
Oct 14th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.80 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # If encoding is not detected assumes Latin 1 (line 22)
  4. # Here are some alternative encodings:
  5. # 1250 - Latin 2 / Central European
  6. # 1251 - Cyrillic
  7. # 1252 - Latin 1 / Western European
  8. # 1253 - Greek
  9. # 1254 - Turkish
  10. # 1255 - Hebrew
  11. # 1256 - Arabic
  12. # 1257 - Baltic
  13. # 1258 - Vietnamese (also OEM)
  14.  
  15. fullPATH=$1
  16. echo $fullPATH >/tmp/subtitleFIX.log
  17. encode=`file -ib $fullPATH|cut -d= -f 2`
  18. echo "encode is : "$encode >>/tmp/subtitleFIX.log
  19.  
  20.  
  21. if [ "$encode" == 'unknown-8bit' ];then
  22.     encode="WINDOWS-1252"
  23. elif [ "$encode" == "utf-8" ];then
  24.     notify-send Fixed!"
  25.     exit
  26. fi
  27. fromFILE=$fullPATH
  28. fromFILEwithNOextention=`echo $fromFILE|cut -d. -f -1`
  29. backupFILE=`echo $fromFILEwithNOextention".bak.srt"`
  30. mv  $fromFILE $backupFILE
  31. iconv $backupFILE -f $encode -t UTF-8 > $fromFILE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement