Renaming files query

I am trying out Opus 9 (9.5.6.0). I am new to Opus but I am having difficulty on how to rename a number of files.

The files are named, eg

Licence something.txt
Licence somewhat.txt
Licence somewhere.txt

I would like to be able to rename them so that I take the first part of the filename ("Licence") and then number them sequentially and retain the extension (".txt"), ie

Licence - 01.txt
Lcience - 02.txt
Licence - 03.txt

I have used Total Commander for many years and doing this quite easy (opening its "Multi-rename tool") in the field for the "rename mask filename" I enter "[N1-7] - [C]" (with [N] standing for filename and [C] standing for counter). [N1-7] standing for the first seven characters of the filename. There is a separate entry for the number of digits for [C] eg 2 or 3 or 1.

Help with this would be greatly appreciated.

Lots of ways you can do it, depending on if you really just want the first 7 characters, or everything up to the first space, or literally the word "Licence", and if you always want .txt or want to handle any extension...

Here are a few different solutions which all work with your three examples:








Leo,

Thank you for the informative replies.

Just a couple of follow up queries:

  1. If I wish to select as the filename part of the old filename but not starting from the beginning, how would I do this with Opus? With Total Commander I would do as follows: eg if the filename had 30 characters, and I wished to start at 4 characters and use the next ten the syntax would be: [N4-13]. (I can just about work out that in one of your examples, that "(.......)" is the regular expression for the first seven characters of the existing name and that "\1" uses those seven characters.)

  2. What does ([^ ]+ )(.*)(\.[^.]+) mean (I am new to regular expressions).

Old name: ....(..........)(.*)(\.txt)
New name: \1 [#].txt

[^ ] means anything but a space
+ means one or more instances

So ([^ ]+ ) means "one or more non space-characters, followed by a single space".

Putting the clause inside brackets lets it be referred to in the "new name" field with \1 (and subsequent bracketed clauses can be referred to by \2, \3, etc).

. means any character
* means zero or more instances

So (.*) means zero or more of any character

\. means a literal dot (any time you want to use a literal character that normally has meaning in regexp, prefix it with a \)
[^.] means anything but a dot, and again + means one or more instances

So (\.[^.]+) means "a dot, followed by any number of non-dots". This isolates the file extension.

(Note that Opus 12 has a checkbox in the Rename dialog to let you not have to worry about file extensions at all when you just want to preserve them.)

More RegEx help here if you need it: RegExp basics: Removing characters from start/end of names