Various simple rename presets

The Rename dialog in Directory Opus lets you store presets which you can re-use to perform common rename tasks. It's also possible to import and export these presets to share them with other people.

Opus 12 example:

Older version example:

Listed below are some rename presets that I find useful.

I've included the regular expressions and wildcards here in case they are helpful examples for people new to regular expressions.

If you just want to use the presets and don't care how they work then you don't need to type them into Opus. Instead, I've attached a zip file with each preset saved as a .orp file.

To load a preset into your Rename dialog, make sure the dialog is in Advanced mode, then select Import... from the File menu. That loads the preset from disk but only temporarily. To add it to your personal list of presets, click the Add button above the list on the right and give it a name.

Here's what all the presets in this post do:

  1. Add - after number -- Regexp ([0-9]+) (.*) to \1 - \2

    03 Survivalism.wma -->
    03 - Survivalism.wma

  2. Add 1. Prefix -- Wildcard * to 1.*

    06 - The Fragile.wma -->
    1.06 - The Fragile.wma

  3. Add 2. Prefix -- Wildcard * to 2.*

    09 - The Big Come Down.wma -->
    2.09 - The Big Come Down.wma

  4. Count Files -- Regexp (.*)\.(.*) to [#].\2

    hello.jpg, there.jpg, etc. -->
    0001.jpg, 0002.jpg, etc.

  5. Make Safe Name -- Regexp (.*)([^-0-9a-zA-Z._]+)(.*)# to \1_\3

    Replaces all "unsafe" characters with underscores, so the filename is suitable for putting on a web server, for example. Everything except letters, numbers and '-' '_' and '.' will be replaced with '_'.

    2.11 - Ripe (With Decay).wma -->

  6. MCE Episode Rename -- Regexp .*(..)_(..)_(200.)_(..)_(..)_(..).dvr-ms to \3-\2-\1 - \4-\

    Used for sorting TV shows recorded with Media Center. Just keeps the date and time, in a nicer format, since I put the shows' names in their parent folders. Easily modified if you want to keep the titles, though.

    The Daily Show with Jon Stewart_More -->
    2007-04-25 -

  7. Move to Artist Subdir -- Regexp ^([^-]+) - (.+)$ to \1\\\2

    The Sanderson Pitch - Dive (album version).mp3 -->
    The Sanderson Pitch\Dive (album version).mp3

  8. Move to Letter Subdir -- Regexp (.)(.+) to \1\\\1\2

    Gail_Porter_002_1024.jpg -->

  9. Move to Year-Album Sudir -- Regexp (.*) - ([0-9][0-9][0-9][0-9]) - (.*) to \1\\\2 - \3

    Audioslave - 2006 - Revelations -->
    Audioslave\2006 - Revelations

  10. Shooting Time -- Wildcard * to Birthday Party\{shootingtime|D#dd-MMM-yyyy} - {shootingtime|} - [#].jpg

    (Opus 11 and earlier: Turn on Enable file information fields.)

    Inserts the EXIF shooting-time value into the names of photos. The "Birthday Party" part can be changed when the preset is used to create whatever subdirectory you want for the images, or removed completely if you don't want to move them as part of the rename.

    P1000291.JPG -->
    Birthday Party\07-Jan-2007 - 01.32 - 001.jpg

    Related thread: Set Created/Modified timestamps to EXIF Shooting Time

  11. Sort Music by Tags -- Wildcard * to {mp3artist} - {mp3year} - {mp3album}\{mp3track|#2} - {mp3title}.{ext}

    (Opus 11 and earlier: Turn on Enable file information fields.)

    Uses tag data inside of music files to generate their filenames and organise them into album folders.

    Track 02.wma -->
    John Coltrane - 1957 - The Ultimate Blue Train\02 - Moment's Notice.wma

  12. Strip Artist -- Regexp (.*) - (.*) - (.*) to \2 - \3

    Nine Inch Nails - 03 - Love Is Not Enough (Live At Rehearsals).flac -->
    03 - Love Is Not Enough (Live At Rehearsals).flac

  13. Strip Number -- Regexp (.*) - (.*) - (.*) to \1 - \3

    Nine Inch Nails - 03 - Love Is Not Enough (Live At Rehearsals).flac -->
    Nine Inch Nails - Love Is Not Enough (Live At Rehearsals).flac

  14. Strip Year from Album -- Regexp (.+) - [0-9][0-9][0-9][0-9] - (.+) to \1 - \2

    Red Hot Chili Peppers - 2006 - Stadium Arcadium - Jupiter -->
    Red Hot Chili Peppers - Stadium Arcadium - Jupiter

  15. Swap Various Artists -- Regexp (.+) - (..) - (.+) to \2 - \1 - \3

    David Bowie - 23 - I'm Deranged (reprise).wma -->
    23 - David Bowie - I'm Deranged (reprise).wma (4.1 KB)

1 Like

There are a few ways you can do this.

Remove everything up to and including the first _ in each filename:

Old name: [^_]+_(.+)
New name: \1
Type: Regular Expressions

Remove the first 3 characters from the start of a filename:

Old name: ...(.+)
New name: \1
Type: Regular Expressions

In the last example the number of dots before the first bracket define how many characters to remove, so if you want to remove 4 characters you'd use ....(.+) instead, and so on.

You have to use a rename script for that, unless you can think up a way to do your rename using a single expression (which is often hard/impossible).

There's an example VBScript script in the forums that you can modify to suit your needs so the only thing you have to learn is VBScript's slightly different regular expression syntax.

I try... :wink:

Insert text just before extension...
Old name: (.*)(\..*)
New name: \1_your_text\2
Type: Regular Expressions

Insert text after x characters...
Old name: (...)(.+)
New name: \1_your_text\2
Type: Regular Expressions

The number of dots under the first bracket define how many characters to keep before your text, so if you want to keep 4 characters you'd use (....)(.+) instead, and so on.

  • Replace Dots with Spaces, except when surrounded by numbers:

    Here's a simple Rename question that comes up sometimes (and requires an unexpectedly complex answer):

    Zippo came up with the solution in his thread:

    Old Name: (.*)(([^0-9])\.|\.([^0-9]))(.*\..*)#
    New Name: \1\3 \4\5
    Type: Regular Expressions

    Or, if you want to make a button instead of using the Rename dialog:

    Rename REGEXP PATTERN="(.*)(([^0-9])\.|\.([^0-9]))(.*\..*)#" TO="\1\3 \4\5"[/code]

    With Opus 12 you can simplify this slightly, as the ignore extension option means you don't have to worry about preserving the last dot. As a bonus, it now works properly with folder names:

    Old Name: (.*)(([^0-9])\.|\.([^0-9]))(.*)#
    New Name: \1\3 \4\5
    Type: Regular Expressions
    :ballot_box_with_check: Ignore Extensions

    You could probably also simplify it using regex asserts, or using a script, but the above works fine as-is.

  • Add spaces around dash (-) characters and collapse multiple spaces:

    Another solution by Zippo from the same thread. Here's how he described it: This flanks '-' characters with a space character on each side if the space character does not already exist. Additionally, multiple space characters are reduced to only one.

    (Note that there are two spaces near the end of the Old Name string.)

    Old Name: (.*)(([^ ])(-)|(-)([^ ])|  )(.*)#
    New Name: \1\5\3 \4\6\7
    Type: Regular Expressions

    Or, as a button:

    Rename REGEXP PATTERN="(.*)(([^ ])(-)|(-)([^ ])|  )(.*)#" TO="\1\5\3 \4\6\7"
  • Add spaces around numbers:

    This is derived from the example above.

    Old name: (.*)(([^0-9 ])([0-9]+)|([0-9]+)([^0-9 ]))(.*\..*)#
    New name: \1\3\5 \4\6\7
    Type: Regular Expressions

    Or, as a button:

    Rename REGEXP PATTERN="(.*)(([^0-9 ])([0-9]+)|([0-9]+)([^0-9 ]))(.*\..*)#" TO="\1\3\5 \4\6\7"

Wow! I can't believe I didn't' stumble on this post before. These presets are incredibly useful!

I have tried to tweak a couple of them to suit my needs. For the "Swap Artists" preset, I changed it so that it would just swap words between a dash (as long as there is only one dash). So for example, if I have a book named "Lewis Carroll - Alice in Wonderland.pdf" it would change it to "Alice in Wonderland - Lewis Carroll.pdf". So I tried the following:

Regexp (.+) - (.+) to \2 - \1

It works, but the problem is that the extension is also swapped, so that it results in:

"Alice in Wonderland.pdf - Lewis Carroll"

Is there anyway for me to change the code so that I can avoid swapping the extension?

Just in case anyone else is interested, solution can be found here:

(2017: Also note that with Opus 12 you can just turn on ignore extension to avoid having to worry about the file extension when changing the rest of the name.)

(Merged discussion into a single post for brevity.)

Try this:

(.*)([-\._ā€“ā€”]+)(.*)# to \1_\3

That's because it isn't looking for space.

Actually, there's an easier way to do all of this these days:

Set the mode to Regular Expressions + Find And Replace.

For Old Name, enter [...]+ where ... are whichever characters you want to replace or coalesce. (Remember regex rules: If you want to include a - character within [...] it has to be the first character, to avoid asking for a range like [A-Z]. Sometimes special characters need escaping with a \ as well.)

For New Name, enter the character(s) you want to replace the matches with. (Space or underscore or whatever you want.)



To find and replace hidden Unicode (UTF-8) characters in filenames, use the regular Expression \uXXXX where "XXXX" is the Unicode identifier. A good resource to lookup UTF-8 codes is

See this forum post for a more thorough discussion on using Unicode with Dopus renaming and scripting.

Thanks to Leo for the solution.