Rename problem with acronyms

I want to rename a batch of files such that...

step 1 - make the filename all lowercase
step 2 - capitalize a specific series of acronyms

Before: "How To Tweak MS Windows XP.doc"
After: "how to tweak MS windows XP.doc"

I've created the following button:

Rename CASE=lower Rename PATTERN=" ms " TO=" MS " FINDREP Rename PATTERN=" xp " TO=" XP " FINDREP @NODESELECT

The problem is that I have found that I need to include spaces in the pattern command or else it will capitalize any occurrence of "xp". But if I do that, any acronyms that are in the first or last positions of the filename won't be picked up. If I execute the button that I've created, I get "how to tweak MS windows xp.doc".

Is there a way to make this work?

Thanks.

Try this:

Rename CASE=lower Rename MATCHCASE REGEXP PATTERN "(.*)(^| )(ms)( |\.[^.]*$)(.*)#" TO "\1\2MS\4\5" Rename MATCHCASE REGEXP PATTERN "(.*)(^| )(xp)( |\.[^.]*$)(.*)#" TO "\1\2XP\4\5" @NODESELECT

That had the following effect. The "MS" was not capitalized.

Before: "How To Tweak MS Windows XP.doc"
After: "how to tweak ms windows XP.doc"

Thanks.

For now I think you will have to split the command into three buttons (e.g. left, right and middle-click of a three-button) which each do one rename on its own.

In the current version of Opus chaining several renames together often doesn't work. I believe it's on the list to be improved in the next version.

I only tested with a single rename command and that definitely does work.

I guess changing "(ms)" to "([mM][sS])" and "(xp)" to "([xX][pP])" should do the trick (not tested).

Greetings,
Jan

@Enigma
No.

@nudel
It works if you omit the first cmd "rename CASE=lower" (also omit the MATCHCASE option).

It seems that DO reexecutes the first cmd with each Regexp.

@nate_dawg
For now, you can change the case in one step, and the replacement in another.

Just as another example of the new rename scripting in Opus 9 - I've created a short script to perform the specified rename.

Just create a new preset and import the .orp file to it. It makes the filename lowercase and makes sure 'ms' and 'xp' are capitalised.
NateDawg.orp (1.81 KB)

Here is another rename script which does the job in a different way, by applying a few regular expressions one after the other:

[Script to perform multiple Regular Expressions)

I think this script will be a good starting point for most cases where you want to do lots of regexp renames.

Did our solutions work for you Nate Dawg?

Yes it worked (THANKS).

I've been testing it a bit and it seems to come up correctly no matter the scenario that I throw at it. Without specifying any spaces on either side of the search term ('XP' in this example), it will only capitalize it if it's found on it's own which is what I want. If I have to specify other occurances such as 'WinXP', that's fine.

I added a comment to Nudel's post about this. I spent an hour or two getting frustrated at the maintenance dialog.
[Script to perform multiple Regular Expressions)

Nate