Skip to content

Instantly share code, notes, and snippets.

@danilvalov
Last active October 28, 2019 05:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danilvalov/77e8b0bc4938d31a833e100fda1fab96 to your computer and use it in GitHub Desktop.
Save danilvalov/77e8b0bc4938d31a833e100fda1fab96 to your computer and use it in GitHub Desktop.
Cyrillic subtitles: .ass to .srt converter (linux, mac os x)
#!/bin/sh
IFS=$'\n'; set -f
for file in $(find ./ -name '*.ass');
do
filename=${file%.ass};
dir=$(dirname "${file}")
if [ -f "$filename".ass ] && [ ! -f "$filename".srt ];
then
asstosrt -n -s utf-8 -o "$dir" "$file" > /dev/null;
if [ -f "$filename".srt ];
then
iconv -c -f UTF-8 -t CP1251 "$filename".srt > "$filename".srt.new;
rm "$filename".srt;
mv "$filename".srt.new "$filename".srt;
echo Converted: "$filename".srt;
fi;
fi;
done;
unset IFS; set +f
@danilvalov
Copy link
Author

danilvalov commented Sep 23, 2017

.ass to .srt converter for cyrillic subtitles (for linux and mac os x)

Preparing:

  1. install python with pip (if you don't have it yet)
  2. install asstosrt and charset packages:
pip install asstosrt charset
  1. download the script ass2srt.sh to any directory
  2. set permissions for the script:
chmod 755 /path/to/script/ass2srt.sh

Using

  1. open directory with .ass files in Terminal: cd /path/to/directory/with/subtitles
  2. run current script: /path/to/script/ass2srt.sh

All *.ass files in the directory and subdirectories will be converted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment