Is this possible?

A swapping-ground for Regular Expression syntax

Is this possible?

Postby trekr » Mon Oct 31, 2005 8:00 pm

First, pardon my ignorance, but is this possible?

I have files currently named:

CANON0002
CANON0009
CANON0031

I need them to be renamed "2", "9" and "31" respectively. In other words, is there a way to delete everything to the left of the first number from the left that is greater than zero? Thanks in advance for any help..
trekr
 
Posts: 6
Joined: Mon Oct 31, 2005 7:51 pm

Postby Admin » Mon Oct 31, 2005 8:10 pm

Hi,

Only by using Regular Expressions or by removing the middle section e.g. "00". THis might take 2 or three batches, e.g. 0-9, then 10-99, then 100-999 etc.


Jim
Admin
Site Admin
 
Posts: 1484
Joined: Tue Mar 08, 2005 8:39 pm

Postby trekr » Mon Oct 31, 2005 8:47 pm

I s there any chance someone would be willing to help with the Regular Expressions? Thanks again.
trekr
 
Posts: 6
Joined: Mon Oct 31, 2005 7:51 pm

Postby trekr » Wed Nov 02, 2005 2:38 am

For money?? :D
trekr
 
Posts: 6
Joined: Mon Oct 31, 2005 7:51 pm

Postby Admin » Wed Nov 02, 2005 8:00 am

How about:

Match field set to:
(CANON)(0)*([1-9]*)

Replace field set to:
\1\3


The donation buttons are on the BRU homepage :-)


Jim
Admin
Site Admin
 
Posts: 1484
Joined: Tue Mar 08, 2005 8:39 pm

Postby trekr » Wed Nov 02, 2005 4:24 pm

Thanks for the reply. I'll be all over the Donate button if I can get this to work..

When I plug in your statements and add a 5 to the "remove first n" section, it works as long as there are no zeros within the new file name I'm trying to create. For example, CANON.0010.jpg becomes "1.jpg" as does CANON1000.jpg.

If I change the [1-9] to [1-0] it leaves the leading zeros (0010.jpg), which doesn't work for what I'm trying to do.

Willing to refine a little more??? Thanks again.
trekr
 
Posts: 6
Joined: Mon Oct 31, 2005 7:51 pm

Postby Admin » Wed Nov 02, 2005 4:31 pm

Sorry, I misread your original posting. Ok, use the same "match" expression, but for "replace" use just

\3


Any better?
Last edited by Admin on Tue Nov 08, 2005 10:37 am, edited 1 time in total.
Admin
Site Admin
 
Posts: 1484
Joined: Tue Mar 08, 2005 8:39 pm

Postby trekr » Wed Nov 02, 2005 4:37 pm

That seems to have removed the need to "remove first n", but it still renames CANON.0010.jpg as 1.jpg.

I'm excited to at least be on the path... :)
trekr
 
Posts: 6
Joined: Mon Oct 31, 2005 7:51 pm

Postby Admin » Wed Nov 02, 2005 4:44 pm

Okay...

Match: (Canon)(0*)([0-9]*)
Repalce: \3



Jim
Admin
Site Admin
 
Posts: 1484
Joined: Tue Mar 08, 2005 8:39 pm

Postby trekr » Wed Nov 02, 2005 4:54 pm

Perfect! Thank you for your help. You saved me from some hand cramps.

I'm headed to the Donation now!
trekr
 
Posts: 6
Joined: Mon Oct 31, 2005 7:51 pm

Help plz

Postby clock345 » Fri Nov 11, 2005 3:46 am

Hi,


Does any one know what is wrong here?
clock345
 
Posts: 7
Joined: Sat Oct 08, 2005 11:37 am

Postby Admin » Fri Nov 11, 2005 7:46 am

?????


Jim
Admin
Site Admin
 
Posts: 1484
Joined: Tue Mar 08, 2005 8:39 pm


Return to Regular Expressions