Renaming files so numbers have zero leading padding

A swapping-ground for Regular Expression syntax

Renaming files so numbers have zero leading padding

Postby noobmaster69 » Fri Aug 09, 2019 2:25 am

Greetings,

I am trying to figure out how to rename my comic collection so numbers (issues) 1-9 have a leading zero like 01-09. I want to preserve volume number (V2016) as well as publish date (2017).

My files now look like this:
    Jessica Jones V2016 #1 (2016).cbz
    Jessica Jones V2016 #10 (2017).cbz
    Jessica Jones V2016 #2 (2017).cbr

And I want to rename them like this:
    Jessica Jones V2016 #01 (2016).cbz
    Jessica Jones V2016 #10 (2017).cbz
    Jessica Jones V2016 #02 (2017).cbr

Any suggestions?
noobmaster69
 
Posts: 2
Joined: Fri Aug 09, 2019 2:09 am

Re: Renaming files so numbers have zero leading padding

Postby therube » Fri Aug 09, 2019 12:05 pm

Is it always space+pound.symbol+number?


1:RegEx
Code: Select all
Match:  (.*\s#)(\d\s)(.*)
Replace:  \10\2\3


Match anything up to space+pound.symbol
Match a single digit followed by a space
Match everything else

Throw an extra '0' in the mix.
therube
 
Posts: 1317
Joined: Mon Jan 18, 2016 6:23 pm

Re: Renaming files so numbers have zero leading padding

Postby noobmaster69 » Fri Aug 09, 2019 7:16 pm

therube wrote:Is it always space+pound.symbol+number?


1:RegEx
Code: Select all
Match:  (.*\s#)(\d\s)(.*)
Replace:  \10\2\3


Match anything up to space+pound.symbol
Match a single digit followed by a space
Match everything else

Throw an extra '0' in the mix.


Yes! It worked! Thank you!
noobmaster69
 
Posts: 2
Joined: Fri Aug 09, 2019 2:09 am


Return to Regular Expressions