Skip to content

Instantly share code, notes, and snippets.

@dilirity
Last active December 15, 2022 20:45
Show Gist options
  • Save dilirity/169ce76032b5fc094d48bf43584217cb to your computer and use it in GitHub Desktop.
Save dilirity/169ce76032b5fc094d48bf43584217cb to your computer and use it in GitHub Desktop.
For rarbg TV shows. This is a small script I wrote to copy subtitles where the episodes are and name them accordingly, so players can detect and load them correctly.
#!/bin/bash
# Put inside root of TV series folder.
# Run using:
# bash fix-rarbg-subtitles-tv-shows.sh
seasons=$(find $1 -mindepth 1 -maxdepth 1 -type d)
for season in $seasons; do
season_subs_folder="${season}/Subs"
episodes=$(find $season -type f | grep -E "\.mp4$|\.mkv$|\.mov$")
for episode in $episodes; do
file_name=$(basename "$episode")
episode_name=${file_name%.*}
english_subs=$(find "${season_subs_folder}/${episode_name}" -type f | grep -E "English.srt$" | tail -n 1)
echo $episode_name
cp "${english_subs}" "${season}/${episode_name}.srt"
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment