Rename Files with Captured Text from Path with Regex

I was largely able to find what I was looking
Using Advanced Rename with "Regular Expressions + Find and Replace"
SEARCH: ^
REPLACE: {parent}.

In this case my parent folder names were a simple \d\d filename

Assuming I have numbered parent directories with text, could I accomplish the same goal in a single step?

ORIGINAL: C:\SomeFolder\01 Some Random Name\01 File Name.jpg

DESIRED
F: (C\:\\SomeFolder\\(\d\d) Some Random Name\\)(01 File Name).jpg
R: $1$2.$3

RESULT: C:\SomeFolder\01 Some Random Name\01.01 File Name.jpg

VS WORKAROUND
STEP1
F: ^
R: {parent}-

RESULT1: 01 Some Random Name#01 File Name.jpg

STEP2
F: (\d\d)(.*?)\#(.*)
R: $1.$3

RESULT2: C:\SomeFolder\01 Some Random Name\01.01 File Name.jpg

I did find "File Information Fields" as a part of earlier versions of Directory Opus. I poked around in 20.20 but didn't find anything related:

Or would I need to turn to scripting to capture text from path to include in file name?

Thank You

You'd need to use a script if you wanted to apply a regex to the parent folder name of the file being renamed, all in a single operation.

(We're thinking of adding a way to apply regex to other things without scripting, but not sure what it will look like yet.)

1 Like

Thanks Leo!

Would absolutely LOVE it if you integrated a way to use regex to alter directory structures.

Going back in time a bit, I needed a way to shuffle songs from sub-folder to parent folder, while at the same time giving the parent folder a custom name (Artist - Album [YEAR][(FLAC|kbps)] through regex.

mp3Tag was my primary metatag tool... but at the time needed a way to deal with changes in directory structure for a set of files.

My primary tool for this was Metamorphose (most recent version I had used was 2.0.8.2b).
https://github.com/metamorphose/metamorphose2
I think mp3Tag may have since found a way to integrate similar?

Maybe there might be something there for Directory Opus to model?
This kind of functionality would strike me as the heart and soul of Directory Opus' versatility.

Looking forward to seeing what you guys come up with!

You could definitely do that in Opus, but would probably need either a script or to do it in two steps (unless you just want to move selected files into a new folder somewhere, rather than to an existing folder which is renamed).

That's already available - have a look at Rename scripts. With full access to all metadata, classic string manipulation and regex there are almost no limits.

Thanks, lxp

Are you specifically referring through scripting?

I've worked quite a bit with dOpus' scripting and custom rules with regex rename files. May have to dig a bit deeper on directory mods
I've realized the potential was there... because of the references in the article I found, I wasn't sure if there wasn't something already baked into dOpus itself to work with it.

Devs have done a superb job with making dOpus better and better and better over the years. Definitely one of my TOP5 software