How to: xxx-nnyy.zzz -> xx0xyy.dnn ?

Post any Bulk Rename Utility support requirements here. Open to all registered users.

How to: xxx-nnyy.zzz -> xx0xyy.dnn ?

Postby pm771 » Wed Sep 03, 2008 3:24 pm

What is the easyest way to rename a group of files following the same pattern like the one in the subject?

The result name in this example will be:
Code: Select all
SUBSTR(cNameOrig,1,2) + "0" + SUBSTR(cNameOrig,3,1) + SUBSTR(cNameOrig,7,2) + ".d" + SUBSTR(cNameOrig,4,2)


I'm not too familiar with regular expressions. Do I need to learn them or is it a better way?

TIA, Eugene
pm771
 
Posts: 8
Joined: Tue Sep 02, 2008 10:58 pm

Re: How to: xxx-nnyy.zzz -> xx0xyy.dnn ?

Postby Admin » Sun Sep 07, 2008 8:33 am

without question, this will be very straightforward using a regular expression.
Admin
Site Admin
 
Posts: 2354
Joined: Tue Mar 08, 2005 8:39 pm

Re: How to: xxx-nnyy.zzz -> xx0xyy.dnn ?

Postby pm771 » Wed Feb 11, 2009 1:11 am

I could not figured out how to change the file extension using regular expressions.

Also, if I need to pad a number with zeroes, how do I do it?

For examle, I need the same expression to make the following renamings:

A1.TXT -> A.001
A12.TXT ->A.012
A123.TXT -> A.123

Could you please clarify the above?

TIA, Eugene
pm771
 
Posts: 8
Joined: Tue Sep 02, 2008 10:58 pm

Re: How to: xxx-nnyy.zzz -> xx0xyy.dnn ?

Postby GMA » Wed Feb 11, 2009 3:22 am

Hi, Eugene:
First of all, go to "Options > Ignore" and check "File Extensions". Then you're gonna need to do three passes, one for each kind of padding (I don't think there's any way to do it just in one). Use the following regular expressions:

For "Ax.TXT" > "A.00x":
MATCH: ([A-Z])([0-9])(.TXT)
REPLACE: \1.00\2

For "Axx.TXT" > "A.0xx":
MATCH: ([A-Z])([0-9]{2})(.TXT)
REPLACE: \1.0\2

For "Axxx.TXT" > "A.xxx":
MATCH: ([A-Z])([0-9]{3})(.TXT)
REPLACE: \1.\2

Of course, this was based strictly on your examples (it'll work for "A[x, xx or xxx].TXT" to "Z[x, xx or xxx].TXT"). But you might need to modify something if your filenames aren't exactly as you described them.
Best regards,

Gabriel.
GMA
 
Posts: 91
Joined: Sun Dec 02, 2007 1:30 pm
Location: Argentina

Re: How to: xxx-nnyy.zzz -> xx0xyy.dnn ?

Postby pm771 » Wed Feb 11, 2009 9:51 pm

Gabriel,

Thank you very much for pointing me in the right direction.

One more question, if I may. When I need to match "." (period character) should I use "\."?

Eugene
pm771
 
Posts: 8
Joined: Tue Sep 02, 2008 10:58 pm

Re: How to: xxx-nnyy.zzz -> xx0xyy.dnn ?

Postby GMA » Thu Feb 12, 2009 10:34 pm

That's right :wink:
GMA
 
Posts: 91
Joined: Sun Dec 02, 2007 1:30 pm
Location: Argentina


Return to BRU Support