by bitmonger » Sat Feb 25, 2012 9:12 am
You are very close to solving the problem. In fact, the sample you gave worked for me but only on the file called PO 24604 EMM.pdf.
The problem is that you need to have something that will match either the - or the space on both ends of the number. The one you tried will match the space but not the -. Stephan suggested using (x|y) which is a good idea, and in this case would have been ( |-).
So then your regular expression would be:
(.*)( |-)(\d+)( |-)(.*)
and you would have 5 captured groups, so the replacement would be \3\1\5.
If you wanted to make the alternating groups non-capturing you could use:
(.*)(?: |-)(\d+)(?: |-)(.*) and then use the \2\1\3 replacement.
This looks more complicated, and here's an alternative and simpler looking option. Consider that what you want to do is split the name up based on the fact the number in the center is bounded by 2 non-numbers. As you correctly used, a number is represented by the \d. A non-number is represented by a \D i.e. a capitol D. Both a space and a dash are non-numbers and would therefore match.
Try (.*)\D(\d+)\D(.*) as your match and \2 \1 \3 as you replace ( or \2-\1-\3 if you want the result to have dashes separating the groups).
Make sure the check box at the top of the RegEx(1) is checked and the Include Ext. is NOT checked.
Also, make sure you actually select the files you want renamed. Users sometimes don't see a change because they haven't selected the files with the mouse.
This solution worked fine on my computer with your filenames.
Hope this helps