Categories
Development Linux Ubuntu

Bash script to extract and convert subtitles

I am having some problems setting up a bash script to automate some stuff.

What is my problem:
I ripped all my BluRays to set up a personal media server (e.g. Emby) for my family. Unfortunately, my files include a lot of VOBSUB or PGS subs which aren’t very compatible.
Due to that, I want to convert them to SUBRIP.

So, I need to:

  1. Extract present subs (MKVToolNix -> mkvextract
  2. Convert PGS -> SUB (BDSup2Sub)
  3. Convert SUB -> SRT (VobSub2SRT)

For the first point I found a script in the www, which I now am trying to expand by point two and three.

This is what I currently have:
https://pastebin.com/LVxWQ7QM

When there is only one SUP file in the folder the script works perfectly file, once there is a second one the check in line 273 does not work anymore.
Example: In a folder are abc.ger.sup and xyz.eng.sup

In line 273 $SRTNAME= xyz.eng.sup and therefore the check does not work.

Hope it is somehow clear what I mean, if not please let me know.

Any hint is appreciated.
Thank you!

Regards

Leave an answer

Your email address will not be published. Required fields are marked *