Skip to content

Instantly share code, notes, and snippets.

@Kedrigern
Created February 6, 2017 21:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kedrigern/6b791b68f2e88d041619f282b4b8342a to your computer and use it in GitHub Desktop.
Save Kedrigern/6b791b68f2e88d041619f282b4b8342a to your computer and use it in GitHub Desktop.
Mass convert name and coding of subtitles
#!/usr/bin/env bash
# Converts subtitles
# from> grimm.301.hdtv-lol.srt
# to> Grimm.S03E01.HDTV.x264-LOL.srt
season=3
num_episodes=22
for i in `seq -w 1 $num_episodes`; do
fr="grimm.${season}${i}.hdtv-lol"
to="Grimm.S0${season}E${i}.HDTV.x264-LOL"
if [ -f "$to".mp4 ]; then
if [ -f "$fr.srt" ]; then
echo "Convert ${fr}.srt to ${to}.srt";
iconv -f "windows-1250" -t "UTF-8" "${fr}.srt" -o "${to}.srt"
elif [ -f "$to.srt" ]; then
echo "Already done $to.srt"
iconv -f "windows-1250" -t "UTF-8" "${fr}.srt" | sponge "${fr}.srt"
fi;
else
echo "Video non exist: $to.mp4"
fi;
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment