Replace "Genre" tag from a Regex using the folder path

Hello, all.

If there was a topic about it, I apollogize but I couldn't find (and got blocked from searching too much hahaha).

I'd like to have some help/guidance/explanation.

I have a folder structure with ~100 itens that looks like these two examples that I copied to the folder "TEST".

G:\TEST\Darkthrone [Nor] #Black Metal, Punk Metal<b><4 folders>:
Darkthrone [1992] A Blaze In The Northern Sky"
Darkthrone [1993] Under a Funeral Moon
Darkthrone [1994] Transilvanian Hunger
Darkthrone [2016] Arctic Thunder

G:\TEST\Monolord [Swe] #Stoner Metal, Doom Metal<b><2 folders>
Monolord [2014] Empress Rising
Monolord [2015] Vaenir

Those are the folders, they have their song files from within it.

I loaded the whole content of the folder "TEST" under Mp3 tag (all Darkthrone and Monolord album).

What I'm trying to do is:

- Replace the field "Genre" with whatever string is after #

For example, for Darkthrone, the genre will become "Black Metal, Punk Metal"
For Monolord, the genre will be Stoner Metal, Doom Metal.

I tried several tag/tag conversions, using the variable %_folderpath% and tested some of my very limited REGEX skills, also tried %_path%, and some other directories variables, also tried to place some %dummy% parameters in several places.

I know it's possible, but I couldn't figure out by myself. I wished someone could point it out and explain to me how it works.


  • Dave

Action format value :mt_act: :

Format: GENRE
FString: $regexp(%_path%,'.+?(#[^\\\\]+).+',$1)

Action Type: Guess Values
Source: %_parent_directory%
Format String: %dummy% #%genre%

Parent directory won't work as some of the OPs examples show 2 or 4 folders deep.

QUOTE (stevehero @ Aug 2 2017, 12:03) <{POST_SNAPBACK}>
Action format value :mt_act: :
Format: GENRE
FString: $regexp(%_path%,'.+?(#[^\\\\]+).+',$1)<!--QuoteEnd--></div><!--QuoteEEnd-->

Thank youm @stevehero!

That's exactly what I wanted. It seems that the REGEX is way more complex than what I thought.

I was going to ask you to explain it to me, but I'll try to figure out myself, since it's not really easy to write the logic down.

Thank you!

QUOTE (stevehero @ Aug 2 2017, 12:03) <{POST_SNAPBACK}>
Action format value :mt_act: :
Format: GENRE
FString: $regexp(%_path%,'.+?(#[^\\\\]+).+',$1)<!--QuoteEnd--></div><!--QuoteEEnd-->

Oh, actually, it's still writing the "#" to the genre. I would need to remove it, and start after that.

Where do you see that in the examples?
My interpretation of "4 folders" and 2 "folders" is just the amount of folders that are in the parent-directory, not a hierarchy of folders.

Use: $regexp(%_path%,'.+?#([^\\]+).+',$1)
Just moved the # outside the capture.

Maybe your right @poster. Read the OP quickly.

Both of you are right. I mean, I didn't say that it was 2 or 4 folders deep, but actually, it's true! some of them (not these ones) are. Haha

Thanks again, @stevehero.

I read your explanation a couple of times. The first part is understandable. I sometimes use these kind of regexps on basic shell scripts, sed commands or simple greps. But that format below still looks very weird for me to understand it easily. I think I need more practice.

btw, the last one, worked perfectly!