How to limit the lenght of episode title?

Support for Windows users
Post Reply
SergeiAK
Posts: 13
Joined: 23 Jul 2024, 12:49

How to limit the lenght of episode title?

Post by SergeiAK »

People hi!
I have an issue with some series. My renaming scheme for episodes is - series name (year) S00E00 - episode name.
Sometimes episode names has very long length, and with windows limit of 256 symbols, i can't rename some files.
How to limit the length of episode title?
User avatar
rednoah
The Source
Posts: 23924
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How to limit the lenght of episode title?

Post by rednoah »

:?: Why though? Do you get an error message? What series / episode are you testing with?


:idea: You can take the first n characters from any given String value like so:

Format: Select all

{ t.take(5) }

:idea: Note that {t} is limited to ~150 characters by default. {plex} also limits the length of each file path component to ~247 characters by default.


:idea: AFAIK, historically, MAX_PATH was a thing, but no longer a thing since ~2016 / Windows Anniversary Update 1607. That said, FileBot does enforce a file path component limit of ~247 characters per folder name / file name for compatibility reasons.
:idea: Please read the FAQ and How to Request Help.
SergeiAK
Posts: 13
Joined: 23 Jul 2024, 12:49

Re: How to limit the lenght of episode title?

Post by SergeiAK »

For example https://www.thetvdb.com/series/jamies-15-minute-meals
My string is:

Groovy: Select all

{drive}  Done/
{ country =~ "RU" ? 'Russian_TVshows' : { country =~ "SU" ? 'USSR_TVshows' : 'TVshows' } }/
{ny} {"{tvdb-$tvdbid}"}/
{episode.special ? 'Specials' : 'Season '+s.pad(2)}/
{ny} - {episode.special ? 'S00E'+special.pad(2) : s00e00} - {t+'.'} - 
[{vf}{'.'HDR+'.'}{'.'source}{' - '+group}]{" - CD$pi"}
I think Russian episode names are to long.

And yes, i had error message
SergeiAK
Posts: 13
Joined: 23 Jul 2024, 12:49

Re: How to limit the lenght of episode title?

Post by SergeiAK »

rednoah wrote: 15 Aug 2024, 11:57 :idea: You can take the first n characters from any given String value like so:

Format: Select all

{ t.take(5) }
This is working as expected, thanks
User avatar
rednoah
The Source
Posts: 23924
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How to limit the lenght of episode title?

Post by rednoah »

:idea: Note that {s00e00} gives you S00E01 for specials by default. Your custom code is unnecessarily complex / redundant, so you can just do:

Format: Select all

{ s00e00 }

:idea: Note that the outermost {...} is semantically completely different from any {...} within the Groovy context, so I would recommend not adding unnecessary Groovy {closures} as to avoid confusion:

Format: Select all

{ country =~ "RU" ? 'Russian_TVshows' : country =~ "SU" ? 'USSR_TVshows' : 'TVshows' }/

:idea: Note that you have incorrect code (e.g. {'.'HDR+'.'}{'.'HDR+'.'}{'.'source} are missing + operators) that always fails and thus does nothing. Even if the code were to work, it would still be expected to work / not work case by case depending on the file at hand, e.g. {hdr} being defined for some files but not others. You'll want to account for undefined bindings like so:

Format: Select all

{ vf }{ '.' + hdr }{ '.' + source }{ ' - ' + group }


:idea: When prototyping a custom format, you'll want to set aside a set of test files and ensure that your test files cover each corner case, i.e. a file where {hdr} works, a file where {source} works, one for country = RU, one for country = SU, etc, so that you can run tests easily as you prototype your custom format.
:idea: Please read the FAQ and How to Request Help.
SergeiAK
Posts: 13
Joined: 23 Jul 2024, 12:49

Re: How to limit the lenght of episode title?

Post by SergeiAK »

Thanks for your advises, it will be very useful
Post Reply