Need help with a file rename

A swapping-ground for Regular Expression syntax

Need help with a file rename

Postby mrp7 » Wed Aug 23, 2017 5:46 pm

Hello! I'm hoping to get some assistance with the following:

Example file names:

05m01 becomes 0005_001
23m34 becomes 0023_034
712m182 becomes 0712_182

The part before "m" needs to be translated to 4 digits padded with zeros, the part after "m" needs to be exactly 3 digits padded with zeros

m becomes a _ (that part I can do :D )

Thanks in advance for any assistance.
mrp7
 
Posts: 2
Joined: Wed Aug 23, 2017 5:38 pm

Re: Need help with a file rename

Postby KenP » Wed Aug 23, 2017 7:51 pm

You can do this in 2 steps with regex.

1.
RegEx (1)
Match: (\d*)m(\d*)
Replace: 000\1_00\2

2.
RegEx (1)
Match: \d*(\d{4}_)\d*(\d{3})$
Replace: \1\2
KenP
 
Posts: 198
Joined: Sat Jul 30, 2016 11:25 am

Re: Need help with a file rename

Postby mrp7 » Wed Aug 23, 2017 11:23 pm

Thanks you, that works!
mrp7
 
Posts: 2
Joined: Wed Aug 23, 2017 5:38 pm


Return to Regular Expressions


cron