by bitmonger » Sun Nov 06, 2011 8:47 pm
I can tell you how to do this in BRU.
Assuming that all you filenames are the pattern shown and that there is only a single occurrence of (x) or (xx) etc. per filename you can do it with a regex in a single pass.
If you have some that are (x), some that are (xx) and some that are (xxx) then you can do it in 2 passes; one to add zero to all (x) to make (0x), and in the second pass to make all (xx) into (0xx)
Use Regex(1) field (Include Ext. NOT checked!)
Match: ^([^(]+\()(\d\).*)
Replace: \10\2
The ^([^(]+\() matches the first part of the filename up to and including the opening parenthesis and captures it in \1.
The (\d\).*) matches a single number, a closing parenthesis and the rest of the filename and captures it in \2
The replace \10\2 puts in the first captured part - the \1, then we add a zero 0, and the rest is tacked on from \2 -
This will change all the single digit (x) into (0x), but it will NOT match or change any (xx).
If you had some (xxx) numbers as well, now you will have only (xx) and (xxx). (All the (x) will have been converted to (xx).)
So to change these (xx) we need to do a second pass.
Second pass:
Now change
Match: ^([^(]+\()(\d\d\).*)
Replace: \10\2
Note the only change was an added \d in (\d\d\).*)
This will make all (xx) into (0xx). It will NOT match or change any existing (xxx).
This can of course be extended to as many digits as you need, expanding the regex each time by one \d.
Hope this helps,
Bit