Trim to maximum file name size but keep suffix

All about user-defined episode / movie / file name format expressions
Post Reply
peatnik
Posts: 8
Joined: 31 Dec 2016, 12:48

Trim to maximum file name size but keep suffix

Post 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!
User avatar
rednoah
The Source
Posts: 22976
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Trim to maximum file name size but keep suffix

Post 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)
:idea: Please read the FAQ and How to Request Help.
Post Reply