Original date + deluxe / remaster date

Hi everyone. Can the script below be optimized or improved at all? I’ll pose one specific case, but am happy to hear your ideas.

The original goal was to include an album’s date at the front of its folder name, in square brackets (for folder-level sorting purposes).

I now realize how many deluxe, remaster, etc editions I have… so I’m considering including both the original and “reissue” date in that spot. Note that in my case I’m sticking with 4 digit (year-only) dates.

While this current script gets the job done, I thought I’d ask if it can be optimized at all to avoid any pitfalls. Specifically, and more advanced… would there be a way to skip repeated dates (such as 1964/1964) when the album is an original release and thus not a deluxe, remaster, etc?

$if2(%albumartist%,%artist%)/
$if(%originaldate%,[$left(%originaldate%,4))/$if(%date%,$left(%date%,4)] )$if($ne(%albumartist%,),%album%)/
$if($gt(%totaldiscs%,1),%discnumber%)$num(%tracknumber%,2) - %title%

That script currently outputs this format for a 2014 remaster:
The Beatles/[1965/2014] Help!/07 - Ticket to Ride.mp3

If my copy was the original 1965 release, it would output:
The Beatles/[1965/1965] Help!/07 - Ticket to Ride.mp3

However, it would seem more tidy with just the singular original date:
The Beatles/[1965] Help!/07 - Ticket to Ride.mp3

Looking forward to see what can be done here, thanks :slight_smile:

One optimization would be to use the $year function.

To check if originaldate and date are not the same year use the $ne function.

I also used helper variables to avoid some code duplication in getting the years from the dates:

$set(_origyear,$year(%originaldate%))
$set(_year,$year(%date%))

$if2(%albumartist%,%artist%)/
$if(%originaldate%,[%_origyear%)/$if($and(%date%,$ne(%_origyear%,%_year%)),%_year%] )$if($ne(%albumartist%,),%album%)/
$if($gt(%totaldiscs%,1),%discnumber%)$num(%tracknumber%,2) - %title%

Not tested :slight_smile:

3 Likes

(edited)

Many thanks for that.

My first test run is Whiskeytown’s Stranger’s Almanac (Deluxe Edition). I get the folder Whiskeytown, then the folder [1997 then the folder 2008] Strangers Almanac.

So being a unique scripting character, the / is splitting the album folder into two folders, rather than simply using / as a character to separate the dates. The two dates are correct though.

My second test, Weezer’s Green Album (original release), gives me just the singular 2001 date, which is great, though of course the same split folder issue above.

And I think the closing ] gets omitted in that Weezer example, which is a casualty of it only using the first / original date.

Yeah, you can’t use the slash in a file name because it is a directory separator. You’ll have to select something else.

Here is a slightly modified version of @outsidecontext’s script (also untested):

$set(_origyear,$if2($year(%originaldate%)),0000)
$set(_year,$if2($year(%date%)),0000)

$if2(%albumartist%,%artist%)/
[%_origyear%$if($and(%date%,$ne(%_origyear%,%_year%)),-%_year%)] $if($ne(%albumartist%,),%album%)/
$if($gt(%totaldiscs%,1),%discnumber%)$num(%tracknumber%,2) - %title%

The changes in setting the temporary variables is to accommodate those cases where there may not be a date returned from the database. I replaced the slash separating the dates with a hyphen to avoid the creation of a new directory. I also moved the “[” and “]” symbols outside of the conditional statements so that they are always displayed.

2 Likes

Thanks, will have a try with your updated version.

Instead of - between the two dates, I suppose + or & would also work… unless they are special characters themselves.

Thanks for sorting out the brackets too.

Must be at least one error in your script as I get this after simply pasting it into the script editor:

1:0:$set: Wrong number of arguments for $set: Expected exactly 2, got 3

Yes, the brackets in $set have to be moved to the end of the line:

$set(_origyear,$if2($year(%originaldate%),0000))
$set(_year,$if2($year(%date%),0000))

$if2(%albumartist%,%artist%)/
[%_origyear%$if($and(%date%,$ne(%_origyear%,%_year%)),-%_year%)] $if($ne(%albumartist%,),%album%)/
$if($gt(%totaldiscs%,1),%discnumber%)$num(%tracknumber%,2) - %title%

(still untested)

2 Likes

Oops. As @ernstlx noted, I had the closing brackets in the wrong spot. Sorry about that.

Thanks. My above tests, the Weezer album and the Whiskeytown Deluxe album… both pass fine. So I’ll throw some more stuff at it tonight. Appreciate the help.

I suppose there are other ways of keeping this year(s) info visible, but the [1997-2008] format works for me.

[1997+2008] or [1997&2008] are both a little harder on the eyes, especially that ampersand jammed in there with the numbers. I think the plus sign might be my choice overall.

1 Like

You could also do something like [1997 (2008)] as well, although I’m not sure that’s any easier to read.

I do mine like this:
1974 - Deep_Purple-Stormbringer-[35th Anniversary Edition]-16BIT-WEB-2009-FLAC

Am I correct in assuming you’re relying on a disambiguation comment on the release for that information?

You mean this part? $if(%_releasecomment%,-[$title(%_releasecomment%)]

Yup, that’s what I meant. You’re relying on the release having a release comment (disambiguation). Many releases just have the (later) date set, and no comment.

I use this format:

(2023) Celtic Death Live at a House Party [EP] [2024 reissue] [FLAC]

Which is done with this line in my script:
$noop([yyyy reissue])$if($eq($year(%date%),$year(%originaldate%)),,[$year(%date%) reissue] )

Thanks. Can you share your complete script so I can have a look at that in context?

This is far from perfect, I would like to add some other stuff, but it does the job. BTW everything relevant to the OP (adding the reissue date, if it doesn’t match the normal release date) is in the single line I shared above.

I swap scripts for VA and audiobooks (slight variations).

$noop(this is a comment - add a bracket after a noop line to activate that script)

$noop(STANDARD ALBUM SCRIPT)

$noop(ARTIST FOLDER)
$if2(%albumartist%,%artist%)/

$noop(ALBUM FOLDER)
$noop(date - album title)\($left(%originaldate%,4)\) $replace(%album%,:,-)
$noop([ep] or [single])$if($in(%releasetype%,single),[single] )$if($in(%releasetype%,ep),[EP] )
$noop([yyyy reissue])$if($eq($year(%date%),$year(%originaldate%)),,[$year(%date%) reissue] )
$noop([soundtrack])$if($in(%releasetype%,soundtrack),[soundtrack] )
$noop([compilation])$if($in(%releasetype%,compilation),[compilation] )
$noop([bootleg])$if($in(%releasestatus%,bootleg),[bootleg] )
$noop([special format])$if($in(%media%,CD-R),[CD-R] )$if($in(%media%,8cm CD),[8cm CD] )$if($in(%media%,Cassette),[cassette] )
$noop([flac] or [bitrate])$if($in(%_extension%,flac),[FLAC])$if($ne(%_extension%,flac),[%_bitrate%])/

$noop(TRACK NAME)
$if($gt(%totaldiscs%,1),%discnumber%-,)$if($and(%albumartist%,%tracknumber%),$num(%tracknumber%,2) ,)$if(%_multiartist%,%artist% - ,)%title%

Hi again @rdswift. Actually, I’d like to incorporate the @aerozol suggestion of [YEAR Reissue] toward the end of the album folder, and therefore only need the original release date at the front (rather than the dual-date idea).

I’ve added some comments, as well as a simple FLAC vs MP3 flag, which I think will be useful to me (specific bitrate is not necessary for me).

So for now, it’s just reconciling my YEAR WORK and ALBUM YEAR sections, which are perhaps clashing a bit, and need to be reduced to just give me that original release year off the top.

$noop(YEAR WORK)
$set(_origyear,$if2($year(%originaldate%),0000))
$set(_year,$if2($year(%date%),0000))

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

$noop(ALBUM YEAR)
[%_origyear%$if($and(%date%,$ne(%_origyear%,%_year%)),+%_year%)] 

$noop(ALBUM TITLE)
$if($ne(%albumartist%,),%album%) 

$noop(ALBUM YEAR REISSUE)
$if($eq($year(%date%),$year(%originaldate%)),,[$year(%date%) Reissue] )

$noop(FILE TYPE FLAC OR MP3)
$if($in(%_extension%,flac),[FLAC])$if($in(%_extension%,mp3),[MP3])/

$noop(TRACK NAME)
$if($gt(%totaldiscs%,1),%discnumber%)$num(%tracknumber%,2) - %title%

would it be this?

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

$noop(ORIGINAL DATE)
[$if2(%originalyear%,$left(%originaldate%,4),$left(%date%,4),0000)] 

$noop(ALBUM TITLE)
$if($ne(%albumartist%,),%album%) 

$noop(ALBUM REISSUE YEAR)
$if($eq($year(%date%),$year(%originaldate%)),,[$year(%date%) Reissue] )

$noop(FILE TYPE FLAC OR MP3)
$if($in(%_extension%,flac),[FLAC])$if($in(%_extension%,mp3),[MP3])/

$noop(TRACK NAME)
$if($gt(%totaldiscs%,1),%discnumber%)$num(%tracknumber%,2) - %title%

I think this gives the four number original date value in my script:

\($left(%originaldate%,4)\)

No need for an if statement I don’t think.