Page 1 of 1
How to limit the lenght of episode title?
Posted: 15 Aug 2024, 11:40
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?
Re: How to limit the lenght of episode title?
Posted: 15 Aug 2024, 11:57
by rednoah

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

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

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.

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.
Re: How to limit the lenght of episode title?
Posted: 15 Aug 2024, 12:29
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
Re: How to limit the lenght of episode title?
Posted: 15 Aug 2024, 12:41
by SergeiAK
rednoah wrote: ↑15 Aug 2024, 11:57

You can take the first n characters from any given String value like so:
This is working as expected, thanks
Re: How to limit the lenght of episode title?
Posted: 15 Aug 2024, 13:35
by rednoah

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

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:

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:

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.
Re: How to limit the lenght of episode title?
Posted: 15 Aug 2024, 15:49
by SergeiAK
Thanks for your advises, it will be very useful