How to customize format? 01x01 vs 1x01

All your suggestions, requests and ideas for future development
Post Reply
JazJon
Posts: 9
Joined: 20 Apr 2012, 22:04

How to customize format? 01x01 vs 1x01

Post by JazJon »

Hello, How can I customize the format output to add the zero before the season number?

For example, I'd like season 01 episode 01 to be named. TV Show name - 01x01 - Episode name
not 1x11

I tried to look over the wiki but I'm not quite following.
http://filebot.sourceforge.net/naming.html

FileBot rocks so far, love it by the way.
User avatar
rednoah
The Source
Posts: 18995
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How to customize format? 01x01 vs 1x01

Post by rednoah »

Check the examples again. I format episode number to two-digit all the time.

Like this:

Code: Select all

{s.pad(2)+'x'}{e.pad(2)}
Note: This expression doesn't work for multi-episodes, but shows the point.
:idea: Please read the FAQ and How to Request Help.
JazJon
Posts: 9
Joined: 20 Apr 2012, 22:04

Re: How to customize format? 01x01 vs 1x01

Post by JazJon »

rednoah wrote:Check the examples again. I format episode number to two-digit all the time.

Like this:
{s.pad(2)+'x'}{e.pad(2)}
Thanks, so the full line I need is: {n} - {s.pad(2)+'x'}{e.pad(2)}- {t}

I think the confusion is because the default syntax used is not shown to me. When you bring up Episode Format, the line is empty/blank so I had no example to go off of. (you're left starting from scratch) :)

Your partial example was enough to figure out the rest thanks.
rednoah wrote:Note: This expression doesn't work for multi-episodes, but shows the point.
I'll be sure to manually rename the multi-episodes that are combined into one giant file.
JazJon
Posts: 9
Joined: 20 Apr 2012, 22:04

Re: How to customize format? 01x01 vs 1x01

Post by JazJon »

Oh... also, will the extra zero pad only be applied to single digits I hope? 1 will be 01 but 11 won't be 011 right?
User avatar
rednoah
The Source
Posts: 18995
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How to customize format? 01x01 vs 1x01

Post by rednoah »

Yep, .pad(n) pads to a n-digit string.

You can handle multi episodes via {episodes} binding. E.g.

Code: Select all

{s.pad(2)+'x'}{episodes*.episode*.pad(2).join("-")}
:idea: Please read the FAQ and How to Request Help.
redgee34
Posts: 1
Joined: 22 Nov 2014, 11:48

Re: How to customize format? 01x01 vs 1x01

Post by redgee34 »

I'd like season 01 episode 01 to be named. TV Show name - 01x01 - Episode name
not 1x11


You can easily check out our best quality 200-101 exam - braindumps exam dumps prepare you well
Last edited by redgee34 on 17 Dec 2014, 10:38, edited 1 time in total.
MC Lamer
Posts: 1
Joined: 28 Nov 2014, 18:40

Re: How to customize format? 01x01 vs 1x01

Post by MC Lamer »

redgee34 wrote:I'd like season 01 episode 01 to be named. TV Show name - 01x01 - Episode name
not 1x11

Code: Select all

{n} - {s.pad(2)+'x'}{e.pad(2)} - {t}

Code: Select all

{n} - {s.pad(2)+'x'}{episodes*.episode*.pad(2).join("-")} - {t}
These expressions should both do what you're looking for, redgee.
hshah
Donor
Posts: 44
Joined: 22 Feb 2016, 22:23

Re: How to customize format? 01x01 vs 1x01

Post by hshah »

I am using this in Filebot on my Synology but for some reason it is skipping the season folder inside the episode folder:

Code: Select all

{n}/{'\''Season '\''+s}/{n} - {s.pad(2)+'x'}{episodes*.episode*.pad(2).join("-")} - {t}
This bit is in there so I have no idea why it is doing that:

Code: Select all

{'\''Season '\''+s}

Code: Select all

[MOVE] Rename [/volume1/EpisodesTEMP/The Simpsons - 27x14 - Gal of Constant Sorrow.mp4] to [/volume1/Episodes/The Simpsons/The Simpsons - 27x14 - Gal of Constant Sorrow.mp4]
User avatar
rednoah
The Source
Posts: 18995
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How to customize format? 01x01 vs 1x01

Post by rednoah »

Because you're trying to access a variable called Season, which doesn't exist, so the {expression} fails.

e.g.

Code: Select all

{n}/{'Season '+s}/{n} - {s.pad(2)}x{es*.pad(2).join('-')} - {t}
I recommend using {sxe} or {s00e00} instead. If you have triple episodes, Plex will want 1x01-03 and won't understand 1x01-02-03 so you might want to do this:

Code: Select all

{n}/{'Season '+s}/{n} - {sxe.split('x')*.pad(2).join('x')} - {t}
:idea: Please read the FAQ and How to Request Help.
hshah
Donor
Posts: 44
Joined: 22 Feb 2016, 22:23

Re: How to customize format? 01x01 vs 1x01

Post by hshah »

rednoah wrote:Because you're trying to access a variable called Season, which doesn't exist, so the {expression} fails.

e.g.

Code: Select all

{n}/{'Season '+s}/{n} - {s.pad(2)}x{es*.pad(2).join('-')} - {t}
I recommend using {sxe} or {s00e00} instead. If you have triple episodes, Plex will want 1x01-03 and won't understand 1x01-02-03 so you might want to do this:

Code: Select all

{n}/{'Season '+s}/{n} - {sxe.split('x')*.pad(2).join('x')} - {t}
I think I was being silly because this is working now:

Code: Select all

{n}/Season {s.pad(2)}/{n} - {s.pad(2)+'x'}{episodes*.episode*.pad(2).join("-")} - {t}
User avatar
rednoah
The Source
Posts: 18995
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How to customize format? 01x01 vs 1x01

Post by rednoah »

You probably just messed up the argument passing. Use an @file instead:
viewtopic.php?f=3&t=3244
:idea: Please read the FAQ and How to Request Help.
nartana
Posts: 20
Joined: 02 May 2019, 22:28

Re: How to customize format? 01x01 vs 1x01

Post by nartana »

I'm using GUI via OSX (all latest).

I'd like {mbps} to appear with two digits on the left side of the decimal point.

e.g. "/EpisodeTitle [06.2 mbps].mkv"

I've tried the following:

Code: Select all

{'/' + t}{' ' + mbps.pad(3)}

Code: Select all

{'/' + t}{' ' + mbps.pad(4)}

Code: Select all

{'/' + t}{' ' + mbps.pad 2}
All of which produce "6.2 mbps" (rather than "06.2 mbps").

Is {string.pad()} uniquely incapable of defining format for {mbps}?

Thank you.
kim
Power User
Posts: 1027
Joined: 15 May 2014, 16:17

Re: How to customize format? 01x01 vs 1x01

Post by kim »

Code: Select all

{media.OverallBitRate.toBigDecimal().div(1000000).round(1).pad(4) + ' Mbps'}

Code: Select all

{'6.2'.toBigDecimal().pad(4) + ' Mbps'}

Code: Select all

{mbps.pad(9)}
nartana
Posts: 20
Joined: 02 May 2019, 22:28

Re: How to customize format? 01x01 vs 1x01

Post by nartana »

Oh, ok — string.pad() applies to the total number of characters, not just numbers.

Your solutions each worked 100% for me. I think I even understand why.

Thank, Kim.
User avatar
rednoah
The Source
Posts: 18995
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How to customize format? 01x01 vs 1x01

Post by rednoah »

Yes, {mbps} will give you a pre-formatted String value, not a numeric value.

Alternatively, {bitrate} will give you the numeric value in bps that you can then round and format yourself to your preferences.
:idea: Please read the FAQ and How to Request Help.
kim
Power User
Posts: 1027
Joined: 15 May 2014, 16:17

Re: How to customize format? 01x01 vs 1x01

Post by kim »

bonus info

Code: Select all

{ String a = '6.2'; a.padLeft(4,'0') + ' *** ' + a.padRight(4,'0') + ' *** ' + a.center(5, '0') }
06.2 *** 6.20 *** 06.20
User avatar
rednoah
The Source
Posts: 18995
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How to customize format? 01x01 vs 1x01

Post by rednoah »

Oh! Even String.format() padding counts based on the String length:

Code: Select all

{String.format('%05.1f', bitrate / 1e6)}

Code: Select all

045.1
:idea: Please read the FAQ and How to Request Help.
nartana
Posts: 20
Joined: 02 May 2019, 22:28

Re: How to customize format? 01x01 vs 1x01

Post by nartana »

Belated thank-you for this addt'l info re. {mbps} parameters. Looking forward to trying it out.

Although I'm more of an 'abstract' thinker (artist) I really appreciate the precision and "absoluteness" of the coding, expressions, etc. And, in that light, I sincerely appreciate your willingness to consider my questions, which haven't always complied with (clearly stated) requested formatting for posts. I'm increasingly able to answer my own questions without posting, because of the input and advice you (@rednoah and @kim) have provided.

<tl;dr> *cheers*
Post Reply