Rename command buttons

I've made a selection of buttons to instantly rename files (primarily mp3s) - I have one that capitalizes first letter of all words (I think this was the template I got from your site which I modified for the others) - one that replaces "_" with a space; one that adds spaces around "-" and one that changes "and" to "&" - these were all pretty easy to make and have proved absolutely invaluable.

I would like to be able to make a button that strips spaces at the end of file names (but not anywhwere else of course) - for example
"Commodores - Heroes .mp3" to "Commodores - Heroes.mp3"

Is there a command that would work for this - eg "delete end space" or a way of indicating that I want to do this using Rename PATTERN=

Would also be interested to know if there is a list of other similar rename patterns - for example one to delete say the first n characters of a file and one that would switch artist/title around (eg Krisp - Sunlight.mp3 to Sunlight - Krisp.mp3)

Thanks for any help


oops! - I think I've posted this in the wrong forum - forgot where I was when I composed it - sorry, shall I repost to correct forum?


[I've moved this topic to Help & Support]

As for your question, you could try my Titlecase Rename program which does a number of the things you're doing in one step - it will also strip leading/trailing spaces I think.

To remove the spaces at the end of filenames (before the file extension) you can use this Regular Expression:

From: (.[^ ])( +)(.[^ .])
To: \1\3

To swap A - B.ext into B - A.ext you can use this Regular Expression:

From: (.+) - (.+)(.[^ .]*)
To: \2 - \1\3

To delete the first 5 characters from a name you can use this Regular Expression:

From: (.....)(.)(.[^ .])
To: \2\3

If you literally want to remove the first 5 characters no matter what, even if it eats into the file extension, then you can use something even simpler:

From: (.....)(.*)
To: \2

In both cases, change the number of dots to eat more characters. Files which have less than 5 characters to eat will be skipped since they cannot match the From expression.

If you want to be able to make these things yourself you just need to read up on regular expressions. None of the above is Opus specific, although there are a couple of extra features that Opus has added to its syntax (e.g. for making expressions recurse (repeat)).