I’d like to automate cleaning up orphan files on my NAS which is serving files to KODI.
When I delete a watched tv episode in KODI, it leaves the corresponding subtitle file untouched in the directory.
I’d like to have a Bash script to recursively go through the TV folder and delete subtitle files (.srt, or sometimes .xx.srt for different language, where xx is the 2-letter language code) which do not have a corresponding .mkv, .avi or .mp4 file.
My folder structure looks like this:
Code:
-TV
|-Show 1
| |-Season 01
| |-Season 02
| |-Show 1 S02E01.mkv
| |-Show 1 S02E01.srt
| |-Show 1 S02E02.avi
| |-Show 1 S02E02.srt
|
|-Show 2
| |-Season 03
| |- Show 2 S03E02.mp4
|- Show 2 S03E02.en.srt
|- Show 2 S03E02.sv.srt
After deleting episodes it looks something like this:
Code:
-TV
|-Show 1
| |-Season 01
| |-Season 02
| |-Show 1 S02E01.srt
| |-Show 1 S02E02.mp4
| |-Show 1 S02E02.srt
|
|-Show 2
| |-Season 03
|- Show 2 S03E02.en.srt
|- Show 2 S03E02.sv.srt