Page 1 of 1

Trim to maximum file name size but keep suffix

Posted: 12 May 2017, 07:45
by peatnik
Hey,

i encrypt files renamed by filebot which inflates the file name length. To avoid hitting the maximum file length, I need to cut the total file name length to around 165 while still keeping some parts of the file name intact, like a custom suffix and of course the file extension.

Example:
SERIES_FORMAT='TV Shows/{n}/{episode.special ? "Special" : "Season "+s.pad(2)}/{n} - {episode.special ? "S00E"+special.pad(2) : s00e00} - {t.replaceAll(/[`´‘’ʻ]/, /"/).replaceAll(/[!?.]+\$/).replacePart(", Part \$1")} {" [$vf, $vc, $ac]"}{"-"+group}{"."+lang}'

In this case 'TV Shows/{n}/{episode.special ? "Special" : "Season "+s.pad(2)}/{n} - {episode.special ? "S00E"+special.pad(2) : s00e00} - {t.replaceAll(/[`´‘’ʻ]/, /"/).replaceAll(/[!?.]+\$/).replacePart(", Part \$1")}' should be cut to 165 - length of '{" [$vf, $vc, $ac]"}{"-"+group}{"."+lang}'.

Is there any way to do that?
Thanks!

Re: Trim to maximum file name size but keep suffix

Posted: 13 May 2017, 02:43
by rednoah
The episode title t is probably the only part of that format that can have an unpredictable length, so I'd just limit the character length of t.

e.g. limit title to 100 characters:

Code: Select all

t.take(100)