How to concatenate filename

A swapping-ground for Regular Expression syntax

How to concatenate filename

Postby Simon » Tue Apr 25, 2006 5:25 pm

I have a series of files in the format -

2006-04-24 01_03.wav
2006-04-24 01_03(1).wav
2006-04-24 01_03(2).wav

and what I want to do is add a (0) to those files that don't have a suffix., thus -
2006-04-24 01_03.wav
becomes
2006-04-24 01_03(0).wav

and I get a sequence of -
2006-04-24 01_03(0).wav
2006-04-24 01_03(1).wav
2006-04-24 01_03(2).wav

By doing so I hope to get a sequence of filenames that will sort in the correct order.

I've figured out that a Match regex of
[0-9]$
selects the right files, but I can't figure out what I should use in the Replace field (other than (0)). Can anyone help?
Simon
 
Posts: 2
Joined: Tue Apr 25, 2006 5:08 pm

Postby Admin » Tue Apr 25, 2006 10:04 pm

Looks reasonably straightforward.

Box 1:

Match: (.*)([0-9])$
Replace: \1\2(0)

Should do the trick.


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

Postby Simon » Tue Apr 25, 2006 11:13 pm

Aha! Thank you Jim. It worked nicely.

I'm going to have to follow up the suggestions made earlier in this forum, because there's clearly something I'm not grasping about Regex expressions.

Thank you again for the suggestion.
Simon
 
Posts: 2
Joined: Tue Apr 25, 2006 5:08 pm


Return to Regular Expressions