Yet another renaming question

I've got a file that's called [YA1515] File Name [1T4C16A].zip and have created a regular expression to remove the numbers and letters in the brackets so I end up with File . But then I also have files that can be like [YA1515]File Name[1T4C16A].zip with no spaces, or files called File Name[1T4C16A].zip with just the end part.

For this I've been using this regular expression:
([.+]) (.+) ([.+])(..+) -> \2\4
Obviously this only works if there's brackets followed by a space on each side of the file name I want to retain.

How can I make a rename that finds anything that is in brackets (regardless of it's position in the file name or if it's followed by a space or not) and removes it, leaving the rest of the file name alone?

And also how do I remove any leading spaces in the beginning of the name and before the file extension (so " File Name .zip" would become "File")?

Normally a regular expression looks for a specific pattern. When there is not a defined specific pattern, or when there's multiple patterns in play, you sometimes need to run the RegExp multiple times. For example, the following will remove one set of square brackets and anything in between those brackets each time it is run.


Replace with

Repeat the above as necessary if there are more than one set of square brackets in the file names.

To remove all leading spaces from a file name, try something like this:

^( +)(.*)

Replace with


The next release of Opus will support repeating regexp renames, so for example you will be able to do:

Find: (.)[.](.*)#
Replace: \1\2

The # will tell Opus to repeat the procedure for as long as the find pattern matches.