padding on the Episode (Part 1)

All about user-defined episode / movie / file name format expressions
Post Reply
DevXen
Power User
Posts: 164
Joined: 12 Oct 2014, 21:15

padding on the Episode (Part 1)

Post by DevXen »

Is it possible to add a 0 to the (Part 1), (Part 2), etc.
This works great to change from: (1) to (Part 1)

Code: Select all

.replacePart(' (Part $1)'))
But I haven't found a way to add a leading 0 to it.
I've tried: .pad(2), but that didn't work, I would assume as the .replacePart, isn't a string to attach it too.


Thanks,
-Dev
User avatar
rednoah
The Source
Posts: 22976
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: padding on the Episode (Part 1)

Post by rednoah »

My replacePart function only supports regex replace syntax.

If you do the replaceAll yourself you can pass in your won replacement logic:

Code: Select all

{'Test (1)'.replaceAll("\\s*[(]([^)]*)[)]\$", { group, match -> ' '+match.pad(2) })}
:idea: Please read the FAQ and How to Request Help.
DevXen
Power User
Posts: 164
Joined: 12 Oct 2014, 21:15

Re: padding on the Episode (Part 1)

Post by DevXen »

It took a while. but I did get it to work. Thank you, once again for your help.
User avatar
deloppoled
Posts: 3
Joined: 31 Mar 2018, 19:07

Re: padding on the Episode (Part 1)

Post by deloppoled »

DevXen wrote: 15 Oct 2014, 21:56 It took a while. but I did get it to work. Thank you, once again for your help.
Hi DevXen.

I was wondering if you still have and would mind sharing the format that you got this to work with?

I'm trying to change "Episode 1" to "Episode 01" As a newbee and non-programmer, it's a bit daunting!

Maybe I could make a change to your code where it reads "Part" and change that to "Episode" is what I'm hoping?

If you don't still have that format thank you for time. I'm a registered user so maybe I will ask rednoah, trying to avoid that since I imagine he is a pretty busy guy.

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

Re: padding on the Episode (Part 1)

Post by kim »

here you go ;)

Code: Select all

{n} - {s00e00} - {t.replaceAll("\\s*[(]([^)]*)[)]\$", { group, match -> ' (Episode '+match.pad(2)+')' })}
User avatar
deloppoled
Posts: 3
Joined: 31 Mar 2018, 19:07

Re: padding on the Episode (Part 1)

Post by deloppoled »

I can't wait to get home to work with it, this will make my collection look exactly like I need it to.

Thank you very much kim! Have a great day.
Dan
User avatar
deloppoled
Posts: 3
Joined: 31 Mar 2018, 19:07

Re: padding on the Episode (Part 1)

Post by deloppoled »

Hello.

The code provided didn't seem to do what I probably poorly explained I was trying to do -- that can be expected! :oops:

I played around without a scintilla of success but luckily got some help from my 22 year old son who stopped by to do his laundry. I guess all people his age just 'get it' when it comes to computers.

Here's what he came up with. It seems to do what I was trying to do. Why? Who knows, but it works! :lol:

Code: Select all

{n} - {S00E00} - {t.replaceAll(".*Episode ([1-9])\$", { group, match -> 'Episode '+match.pad(2) })}
A lot of British shows come with "Episode 1" through 9 so this makes them "Episode 01" through 09. And then from Episode 10 onwards, it leaves them as they are. Basically so everything has two digit episode numbers.

I thought I should post this up here in case there's any other 'puter illits that want to do that.

Thank you again for your time kim!
Great days to all.
Dan
Post Reply