Release Type in folder structure

filenaming
taggerscript
Tags: #<Tag:0x00007f64694a9c58> #<Tag:0x00007f64694a9988>

#1

I could really use some help with this as I seem to be getting nowhere on my own. This is my current script for file naming of single album artist albums:

$noop(Artist)
$if2(%albumartist%,%artist%)/

$if(%album%,
$noop(Album Tracks)
$if($eq($or(%originaldate%,%date%),1),
[$left($if2(%originaldate%,%date%),4)] %album% [$left($if2(%date%),4) - %label% - %catalognumber%] [%media%]/,
%album%)/
$if($gt(%totaldiscs%,1),$if(CD%discnumber%/, CD%discnumber%/),)
$num(%tracknumber%,2). %artist% - %title%,

Which gives me this folder structure:
D:-\Music/#Artists [A-Z]\A\ABBA/[1974] Waterloo [1974 - Polydor - 2489 085] [Vinyl]

What I would like to do is create a new folder depending on the release type. For the example used above it would look like this:
D:-\Music/#Artists [A-Z]\A\ABBA\Albums/[1974] Waterloo [1974 - Polydor - 2489 085] [Vinyl]

Or if the album is a compilation of a single artist (anthology):
D:-\Music/#Artists [A-Z]\A\ABBA\Anthology/[2006] Number Ones [2006 - Polydor - 1712219] [CD]

Same goes for Live, Singles and EP’s.

I’ve been messing around with it for a bit but can’t seem to get it to work properly and it’s hard to imagine that this should be so difficult and for someone who’s well-versed in regex it’s probably super-easy.

Any assistance is greatly appreciated!


#2

I’m not 100% sure I understand what you’re after, but you might try something like this:

$set(_releasetype,Album)$noop( ** This is the default value. ** )
$if($eq(%_primaryreleasetype%,Single),$set(_releasetype,Single),)
$if($eq(%_primaryreleasetype%,EP),$set(_releasetype,EP),)
$if(%_secondaryreleasetype%,
    $if($rsearch(%_secondaryreleasetype%,Compilation),$set(_releasetype,Anthology),)
    $if($rsearch(%_secondaryreleasetype%,Live),$set(_releasetype,Live),)
,)

Then insert the variable %_releasetype% in the appropriate spot in your naming template.

Part of the problem is that you’re evaluating both the primary and secondary release types to determine the release type in your naming scheme.

This is a quick hack and I haven’t tested it. Also, I’m sure there must be a more efficient way to code this, but this might help you get started.


#3

You’ll be wanting to look at the %releasetype%/%_secondaryreleasetype% and %_primaryreleasetype% variables. Either of the first will indicate whether the album is a compilation, and while that does overlap with Various Artists releases, it should also (assuming proper data) be set for single-artist anthologies; the last is a simple way of extracting what you want for the folder name rather than wrestling with regexes. Since it sounds like you want those to override the other types whether they’re albums, EPs, or (somehow) singles, you’ll want to check for it first – I’m not sure whether you wanted Various Artists to be handled differently, but you seem to have a good enough handle on scripting to add the check if you need it (I recommend $eq(%musicbrainz_albumartistid%,89ad4ac3-39f7-470e-963a-56509c546377) though you may want to add a bit extra to support non-MB releases).

$if($inmulti(%releasetype%,compilation),
	Anthology,
	$upper($left(%_primaryreleasetype%,1))$right(%_primaryreleasetype%,$sub($len(%_primaryreleasetype%),1))
)

@rdswift Doesn’t look bad, though it’s definitely more manual than mine. The one thing I’m not sure about are the $eq and $rsearch tests; are they case sensitive? The variables seem to be set to all lowercase, though wrapping them in $lower would definitely be safest.


#4

The one thing that I’m wondering about is the “Live” type. @Tybot had indicated that was one release type designation desired. According to the notes in https://musicbrainz.org/doc/Release_Group/Type the “Live” type is only available as a secondary type, so your code will never return it. Good suggestion on forcing the case on the checks and the use of $inmulti() rather than the $rsearch(). I always forget about that one.


#5

Ah, didn’t notice the request for “Live”, thanks! That’s easy enough just by wrapping the code in itself, though, @Tybot, you do have to decide which you want to take precedence. I personally figure a live compilation would be best sorted under Live, but you may like it the other way around. One thing to note is that this might not be the best solution if you wanted releases with both secondary types to be handled differently than either singularly, but those releases are probably rather rare anyway.

$if($inmulti(%releasetype%,live),
	Live,
	$if($inmulti(%releasetype%,compilation),
		Anthology,
		$upper($left(%_primaryreleasetype%,1))$right(%_primaryreleasetype%,$sub($len(%_primaryreleasetype%),1))
	)
)

#6

I’m right in the middle of a massive tag-correction project so I’ll read through your replies more thoroughly asap. I wanted to clarify some things as they were brought up.

Forget about Various Artists compilations completely, that’s not what this thread is about. I’m doing them manually as it is right now and it’s not a huge ordeal. I understand that including VA’s in the thread topic makes the issue 100x harder to solve so as I said, forget about it.

To clarify my issue further.

Current folder structure looks like this:

1st folder (Artist)
2nd folder (Albums)

What I wanted to do is add a third folder in-between the two described above that would separate all albums by that artists based on what kind of release type it is and it would look like this:

1st folder (Artist)
2nd folder (Release Type (Regular Album/Live Recording/EP/Anthology)
3rd folder (Albums)

Huge thanks for taking the time to reply, guys!

Edit: I’ve read the replies and I fear I may have been a bit unclear in my first post. It was written in frustration and in a bit of a hurry and it came out really sloppy.

To clarify it even further: If the releasetype tag is: “album; compilation”, I want the album to be placed in a folder named “Anthology”.

If the releasetype tag is: “album”, I want the album to be placed in a folder named “Album”.

If the releasetype tag is: “single”, I want the album to be placed in a folder named “Single”.

The folder structure for e.g The Beatles would look like this:

/ B / The Beatles / Anthology / [name of the album]
/ B / The Beatles / Album / [name of the album]
/ B / The Beatles / Single / [name of the album]

So the question is; how do I place albums in these folders based on the information in the releasetype tag?

Thanks again for your time guys and sorry for the confusion.


#7

So to clarify, just the three types? The reason I ask is because you initially mentioned something about “Live” and “EP”.


#8

That’s what I was thinking in writing my functions, and looks like what @rdswift had in his mind as well, though as he just said, we implemented a larger pool of potential folders. I just am using a couple “hidden” tags to make the script simpler – the Picard tags page and the “Show script variables” plugin are invaluable for figuring out what you have to work with, beyond just what you see in the bottom pane.

Since you said you already have a script getting you most of the way there, we both just gave you the additional lines you’d need to add the extra folder into the hierarchy, and left it to you to put it in context; for his implementation, you’d put %_releasetype%/ immediately after your $noop(Album Tracks) line while for mine you’d either put the entire $if function in the same place (with a slash after it) or save it into an underscore-prefixed variable and do the same as with his.


#9

No, the ones you mentioned as well. I forgot to add “etc” to my example…

@WovenTales
The thing is, I’m not sure I want Picard to change the releasetype tag, which I figured is what rdswifts code would do. Some soundtracks for example has the releasetype tag “album; compilation” and the script would then change that to Anthology, which would be incorrect. I basically want to create the appropriate folders based on existing releasetype tag. After that, I use MP3Tag to change it to the way I want.

Creating a folder based on the information in the releasetype tag is what I’m struggling with.

I feel like I’m on the right path with this:

$noop(Artist)
$if2(%albumartist%,%artist%)/
$if($eq(%_primaryreleasetype%,Single),$set(_releasetype,Single),)
$if($eq(%_primaryreleasetype%,EP),$set(_releasetype,EP),)
$if(%_secondaryreleasetype%,
$if($rsearch(%_secondaryreleasetype%,Compilation),$set(_releasetype,Anthology),)
$if($rsearch(%_secondaryreleasetype%,Live),$set(_releasetype,Live),)/
$if(%album%,
$noop(Album Tracks)
$if($eq($or(%originaldate%,%date%),1),
[$left($if2(%originaldate%,%date%),4)] %album% [$left($if2(%date%),4) - %label% - %catalognumber%] [%media%]/,
%album%)/
$if($gt(%totaldiscs%,1),$if(CD%discnumber%/, CD%discnumber%/),)
$num(%tracknumber%,2). %artist% - %title%,

$noop(Non-Album Tracks)
%title%
)

)

But I need to change $set to “create folder” instead.


#10

Ah, of course. Tripped me up a bit on my first readthrough as well. It’s actually using a completely different name – %releasetype% the official tag has no relation internally to the %_releasetype% with an underscore in the script – but that’s why I generally like something more along the lines of %_savereleasetype% or %_releasefolder% to make it more clear.

EDIT: @rdswift’s logic depends on setting and re-setting a single variable which eventually (outside of the snippet) gets added to the path, so it’s not really possible to adapt in a more direct way. Mine emits the folder name itself (though the folder divider needs to be added) and needs to be captured if you want to use it in variables. They’re both perfectly valid approaches, but we’re coming at it from different directions.


#11

I’ve taken your code and plugged in the code that @WovenTales provided, because it was cleaner than what I provided. This is the result:

$noop(Artist)
$if2(%albumartist%,%artist%)/
$if($inmulti(%releasetype%,live),
	Live,
	$if($inmulti(%releasetype%,compilation),
		Anthology,
		$upper($left(%_primaryreleasetype%,1))$right(%_primaryreleasetype%,$sub($len(%_primaryreleasetype%),1))
	)
)/
$if(%album%,
$noop(Album Tracks)
$if($eq($or(%originaldate%,%date%),1),
[$left($if2(%originaldate%,%date%),4)] %album% [$left($if2(%date%),4) - %label% - %catalognumber%] [%media%]/,
%album%)/
$if($gt(%totaldiscs%,1),$if(CD%discnumber%/, CD%discnumber%/),)
$num(%tracknumber%,2). %artist% - %title%,

$noop(Non-Album Tracks)
%title%
)

I didn’t check any of your existing code, other than to make sure that the brackets matched, because I assumed that you already had it doing what you wanted. I did a quick check in Picard and it seems to be doing what you want with respect to the release type. I trust that you can use this to get most of the way toward your goal.


#12

I’m not able to test it fully at the moment but at first glance it looks to be exactly what I need. It’s going to need some tweaking and I’ll need to add a few lines to make it cover all the release types, but I’m confident I can extrapolate that information based on what you’ve provided and what I’ve learned in the last couple of hours.

Thank you both so very much for the assistance and the shove in the right direction!