.srt file handling

All about user-defined episode / movie / file name format expressions
Post Reply
ChefGregS
Posts: 99
Joined: 30 Mar 2016, 11:14

.srt file handling

Post by ChefGregS »

I wish that someone would come up with a standard format for naming these types of files but apparently, that is never going to happen. So I have a question to hopefully save me, well, I already have no hair to pull out...so (lol). How can I take all these various naming formats and make them so they work with Filebot?

I know that the supposed standard standard is: filename.en_US.srt with lowercase language and uppercase country code. But most don't use the country code unless they are doing subs in say eng_UK, eng_US, eng_IE, etc.... For my library, since my current script doesn't handle it well, I usually just delete most sub files that Filebot thinks are the same after they process. I'd like to change this.

Quick example of what I am looking at now. (and yes, I know Filebot handles them currently, but it's not handling how some are named....like this:)

Movie Folder
- Subs Folder
- English.srt (this is the same as the one in the main folder, just doesn't contain the movie name (yes, I know you know this))
- SDH.eng.srt
- CC.eng.srt
- This Movie.mp4
- This Movie.srt


Using the above I end up with this output:

This Movie.mp4
This Movie.eng.srt
This Movie.eng.srt
This Movie.eng.srt
This Movie.eng.srt

My problem is that now when I click to rename it shows that 3 will be removed. I don't like that but it's simply quicker and easier to just click them into oblivion. However, I usually will rename the SDH files manually to keep them.

I have found that when just using the {subt} at the end of my code it seems to handle the language correctly but not anything else. Well, that's not entirely true. Take the SDH file. The {subt} doesn't like that format. However, if I manually rename it to eng-SDH.srt it handles that perfectly and outputs .eng.SDH.srt

All that to ask how to automate all of that? I guess I could do the text file read to fix SDH.eng > eng.SDH but is that the only way? And I am guessing that code in the script would be:

{any{csv('M:/replacesrt.csv').get(srt)}{srt}{"eng"} } Maybe? And then I guess I would fill that will all the variations I find.

Or, is there a simpler way for Filebot to figure out that sdh.eng is the same as eng.sdh and name it that way? And then what about all the language/country codes. Is there no way for Filebot to handle them better? Or at all? I seem to have the issues like above with several of the languages. Portuguese and Chinese are perfect examples...as is Spanish. They all can have various flavors for various locations.

I guess before anything the question would be what does Filebot want to see and what variations does it spit out?

Greg
User avatar
rednoah
The Source
Posts: 23002
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: .srt file handling

Post by rednoah »

Fortunately, you can just write your own custom format, since the target file path is ultimately up to your custom format over which you have absolute control. FileBot by default forces everything into the common case which is .eng.srt or .eng-SDH.srt (ISO 639-3 language codes only; no support locale strings) as everything else is rare and / or requires you to make assumptions (eng -> en_US, no language -> en_US, etc) that FileBot cannot make for everyone, but that you can make for yourself.


e.g. add "Subs" folder to target path for subtitle files that are in a "Subs" folder:

Format: Select all

{ folder.name == /Subs/ ? 'Subs' : null }
e.g. add "-SDH" if the file name contains the "SDH" keyword:

Format: Select all

{ fn =~ /SDH/ ? '-SDH' : null }
e.g. add "_US" if the file name contains the "_US" keyword:

Format: Select all

{ fn =~ /_US/ ? '_US' : null }
e.g. add ".eng" if the file at hand is a subtitle file and the language is undefined:

Format: Select all

{ f.subtitle ? any{ '.' + lang }{ '.eng' } : null }
And so on. You will want to collect lots of subtitle files that represent all the various corner cases, and the prototype your format with rapid trial & error testing.




tl;dr you can write your own code to interpret the original subtitle file name and then produce the desired target subtitle file name
:idea: Please read the FAQ and How to Request Help.
ChefGregS
Posts: 99
Joined: 30 Mar 2016, 11:14

Re: .srt file handling

Post by ChefGregS »

Thank you so much red... You know, I have this so much harder in my head than it is...then you post the example and it makes so much sense. So many times I read your replies and think, I honestly should have thought of that. I have read so many examples of things and look at how to put things together, and why the code does what it does....but then when I need to do something I never seem to look for the easy solution. Always knowing it's there.... LOL

again for the 70th time or so.... Thank you so very much! This is the reason I will always have my Filebot license!!!!

Greg

Oh, and just an FYI: I ONLY use the rename feature of the app. I mean, from the videos I have watched I see it is so much more powerful than what I use it for...I almost wish I had a reason to use the rest of it. :) What's scary is that I am 100% sure I could use it and would love using it but then my life would be much more complicated because those are more rabbit holes I probably should not go down!!! My friends already laugh at how much time I spend on my file formats, names, Plex work (fixing errors, fixing posters, creating play-lists, etc...)
ChefGregS
Posts: 99
Joined: 30 Mar 2016, 11:14

Re: .srt file handling

Post by ChefGregS »

rednoah wrote: 03 Jan 2024, 17:33
And so on. You will want to collect lots of subtitle files that represent all the various corner cases, and the prototype your format with rapid trial & error testing.

you can write your own code to interpret the original subtitle file name and then produce the desired target subtitle file name
I will be doing exactly this. And your simple suggestion of testing JUST what you need to figure out has saved me sooooo much time and headaches. Another 'how did I not think of that' moment. LOL

Greg
User avatar
rednoah
The Source
Posts: 23002
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: .srt file handling

Post by rednoah »

Cheers.

The more you get familiar with custom formats for the purpose of media renaming, the more you will want to use custom formats for the purpose of any kind of batch renaming, aka Plain File Mode. It's a steep learning curve, but if you've already familiarized yourself with a bit of coding for reasons, then all the other GUI renaming tools feel so limited because you can only do so much with checkboxes and comboboxes.
:idea: Please read the FAQ and How to Request Help.
Post Reply