Created
February 6, 2017 21:07
-
-
Save Kedrigern/6b791b68f2e88d041619f282b4b8342a to your computer and use it in GitHub Desktop.
Mass convert name and coding of subtitles
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
#!/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