Help finishing/clean up simple script

Hello.

I am trying to reorganize my whole massive library, which is a mix of flac and mp3 files of various genres. What I want is a single library with each file type mixed together (see example below). That being said, I’d like to apply different naming scheme for each of these extensions. For flac files, I’d like to include detailed info such as {label, catalog #, format}, etc.

I know few basic scripts, but even after many attempts, I didn’t manage to finish it the way I want.
Here is what I got so far:

(if FLAC)
$if2(%albumartist%,%artist%)/

$if($ne(%albumartist%,),%album% \($left(%originalyear%,4)\) [$upper(%_extension%)]) {%label%, %catalognumber%, %media%}/

$if($gt(%totaldiscs%,1),%discnumber%-,)$if($ne(%albumartist%,),$num(%tracknumber%,2) - ,)%title%

(it doesn’t remove empty spaces if certain metadata is missing, eg. catalog # or label - not sure how to do that)

(if MP3)
$if2(%albumartist%,%artist%)/

$if($ne(%albumartist%,),%album% \($left(%originalyear%,4)\)/

$if($gt(%totaldiscs%,1),%discnumber%-,)$if($ne(%albumartist%,),$num(%tracknumber%,2) - ,)%title%

This is how I’d like it to look like:
for FLAC albums:
“Artist\Album (year) [FLAC] {label, cat#, media}” or if label/cat# is unknown then “Artist\Album (year) [FLAC] {media}”, etc.

for MP3 albums:
“Artist\Album (year)”

So both mp3 and flac albums will be under the same Artist folder.
Anyone would be kind enough to point me in the right direction? Thanks!

$if2(%catalognumber%,%catalognumber\, ,)

At least I think that’s how you’d put a comma into an if statement. I’m at work so I can’t test it.

Thanks for feedback!
Perhaps I can skip the commas all together if it makes it easier. I have tried the script, but it gave me an error. Not sure if this was intended, but wasn’t there meant to be % after the 2nd catalognumber? Even with that included, it doesn’t seem to be doing what its meant to.

$if($ne(%albumartist%,),%album% ($left(%originalyear%,4)) [$upper(%_extension%)]) {$if2(%label%,%label%, ,)$if2(%catalognumber%,%catalognumber%, ,)$if2(%media%,%media%)}/

Results:
Hilal (2008) [FLAC] {Season of MistSOM 179CD}
Salam (2011) [MP3] {Season of MistSOM235CD}
Sofia (2014) [MP3] {Season of Mist, CD}
A Call to Arms EP (2017) [FLAC] {, , Digital Media}

What I want to achieve:
Hilal (2008) [FLAC] {Season of Mist, SOM 179, CD} or
Hilal (2008) [FLAC] {Season of Mist SOM 179 CD} (without commas, this might actually be prefered)

Perhaps if you built your third (catalogue / media) section in stages, you could try something like (untested code):

$noop( Store your separator to a tag for easy switching if desired.  Currently set to a single space. )
$set(_sep, )

$noop( Initialize catalogue / media tag. )
$set(_cat,%label%)

$noop( Check and add remaining parts with separator if appropriate. )
$if(%catalognumber%,$set(_cat,%_cat%$if(%_cat%,%_sep%,)%catalognumber%))
$if(%media%,$set(_cat,%_cat%$if(%_cat%,%_sep%,)%media%))

$if(%albumartist%,%album% ($left(%originalyear%,4)) [$upper(%_extension%)]) {%_cat%}/

If this isn’t what you want, perhaps it will help generate some other ideas.

1 Like

That is pretty neat and indeed functions exactly as needed so far (tested about 5 albums), thanks!

Now I only need to somehow include the detection of lossy music and sort the name accordingly. I downloaded this script Categorizing lossless music, but I am still battling with how to make it work with my naming script.

For lossy music, I’d just want to have a simple $if(%albumartist%,%album% ($left(%originalyear%,4)) “Aritst - Album (Year)”

Any hints or feedback regarding that is very appreciated.

Okay, how about something like this (once more, untested code):

$noop( Store your separator to a tag for easy switching if desired.  Currently set to a single space. )
$set(_sep, )

$noop( Create multi-value tag of lossless extensions for testing. )
$setmulti(_lossless_ext,FLAC; OGGFLAC; APE; OFR; TAK; WV; TTA; WAV)

$noop( Store upper case file extension to a tag for ease of testing. )
$set(_ext,$upper(%_extension%))

$noop( Determine if extension is a lossless type and store result in a tag. )
$set(_lossless,$inmulti(%_lossless_ext%,%_ext%))

$noop( Initialize catalogue / media tag. )
$set(_cat,%label%)

$noop( Check and add remaining parts with separator if appropriate. )
$if(%catalognumber%,$set(_cat,%_cat%$if(%_cat%,%_sep%,)%catalognumber%))
$if(%media%,$set(_cat,%_cat%$if(%_cat%,%_sep%,)%media%))

$if(%albumartist%,%album% ($left(%originalyear%,4))$if(%_lossless%, [%_ext%] {%_cat%},)/

The caveat is that it is basing the lossless decision on the file extension only. Again, if it doesn’t do what you want, it might give you some ideas and a starting point.

1 Like

Just wanted to let you know that the script works pretty much straight off the bat and it has been super helpful. Now that I understand it a bit better, I might be able to further modify it if needed. Thank you!

1 Like