Picard Script Help

@rdswift or anyone else :grin:

Bob, I made some changes to your script:

$noop(
########################################################################
#                                                                      #
#  Set File Path                                                       #
#                                                                      #
########################################################################
)
$noop(
$if($eq(%_nAlbumType%,Classical),$set(_nFilePath,%_cClassical%/%_nFAAPS%/%_nYear% %_nANT%/))
)
$if($eq(%_nAlbumType%,Classical),$set(_nFilePath,%_cClassical%/%_nYear% %_nANT% [%discsubtitle% ] [%media% ] [%releasetype%]/))
$if($eq(%_nAlbumType%,Soundtrack),$set(_nFilePath,%_cSoundtrack%/%_nYear% %_nANT% [%discsubtitle% ] [%media% ] [%releasetype%]/))
$if($eq(%_nAlbumType%,Other),$set(_nFilePath,%_cOther%/%_nYear% %_nANT% [%discsubtitle% ] [%media% ] [%releasetype%]/))
$if($eq(%_nAlbumType%,Single),$set(_nFilePath,%_nInitial%/%_nPAAS%/%_cSingles%/%_nYear% %_nANT% [%discsubtitle% ] [%media% ] [%releasetype%]/))
$if($eq(%_nAlbumType%,Standard),$if($eq($if2(%musicbrainz_albumartistid%,%_cVariousArtistID%),%_cVariousArtistID%),
    $set(_nFilePath,%_cVariousArtist%/%_nYear% %_nANT% [%discsubtitle% ] [%media% ] [%releasetype%]/),
    $if($eq($if2(%musicbrainz_albumartistid%,%_cUnknownArtistID%),%_cUnknownArtistID%),
        $set(_nFilePath,%_cUnknownArtist%/%_nYear% %_nANT% [%discsubtitle% ] [%media% ] [%releasetype%]/),
        $set(_nFilePath,%_nInitial%/%_nFAAPS%/%_nYear% %_nANT% [%discsubtitle% ] [%media% ] [%releasetype%]/)
)))


$noop(
########################################################################
#                                                                      #
#  Set File Name                                                       #
#                                                                      #
########################################################################
)
$if($eq(%_nAlbumType%,Classical),$set(_nFileName,%_nTNum%%_nFeat% %_nTNT% [%_bits_per_sample% bit ] [ %_bitrate% kpbs ]))
$if($eq(%_nAlbumType%,Soundtrack),$set(_nFileName,%_nTNum% %_nTNT%%_nFeat% [%_bits_per_sample% bit ] [ %_bitrate% kpbs ]))
$if($eq(%_nAlbumType%,Other),$set(_nFileName,%_nTNum% %_nTNT% [%_bits_per_sample% bit ] [ %_bitrate% kpbs ]))
$if($eq(%_nAlbumType%,Single),$set(_nFileName,%_nTNum% %_nTNT%%_nFeat% [%_bits_per_sample% bit ] [ %_bitrate% kpbs ]))
$if($eq(%_nAlbumType%,Standard),$set(_nFileName,%_nTNum% %_nTNT%%_nFeat%  [%_bits_per_sample% bit ] [ %_bitrate% kpbs ]))

For file path: I want it to show the disambiguation field, but I do not think %discsubtitle% is the correct field. Plus, I would prefer () around it instead of [] but I was having problems adding ()…I must be doing it wrong and missing the difference between the two. (It’s been a long time since I’ve done any of this…lol…decades… :crazy_face:)

For file name: The bitrate shows as 256.0 kbps. How do I remove anything after the period? I know their is a way but I do not remember.

Thanks for your help!!!

1 Like

I think you might want the %comment% tag rather than %discsubtitle%.

Remember that opening and closing brackets need to be escaped, so they would be entered as “\(” and “\)” rather than just “(” and “)”.

I think you might be able to do something like (untested code):

$set(_bitrate,$rreplace(%_bitrate%,\\.[0-9]*\$,))

Please let me know if I’ve misunderstood somthing or if something doesn’t work.

3 Likes

@rdswift Thank you so much!!

@outsidecontext Hi, how did you do that?

1 Like

He added a line:

```taggerscript

before the start of the script, and

```

after the end of the script. This tells the program to format the text in between as a script and not apply other (markdown) formatting.

2 Likes

It is actually _releasecomment Put me on the right path :slight_smile:

1 Like

I’m getting an end of script error. I tried looking up the double escape, asterisk, etc. to try and figure it out but I must not be looking it up correctly to find the answer. Any ideas? Also, anything from the disambiguation field is adding and underscore _ between words and before and after my (). It looks like you have a section in your script that deletes those for other fields. I’m guessing that would have to be updated for _releasecomment too?

Yeah, I forgot the closing bracket for the $set() command. You need to change the line to:

$set(_bitrate,$rreplace(%_bitrate%,\\.[0-9]*\$,))

Sorry about that.

1 Like

Ohh…and if the disambiguation is empty it shows : _ (_ _) _ Is their something I can put in that if the field is blank(empty) to skip it?

OMG…I couldn’t figure that out…LOL

That worked…so to explain this to me…the double escape means anything before the period stays as is…but what does the asterisk do?

Can you post the line(s) where you set/apply the disambiguation comment? To avoid the extra brackets you will need to enclose that in a check if the disambiguation exists or is blank.

I’m guessing that the underscores are due to you adding some improper characters for a file path, or perhaps the disambiguation comment includes such characters.

########################################################################
#                                                                      #
#  Set File Path                                                       #
#                                                                      #
########################################################################
)
$noop(
$if($eq(%_nAlbumType%,Classical),$set(_nFilePath,%_cClassical%/%_nFAAPS%/%_nYear% %_nANT%/))
)
$set(_bitrate,$rreplace(%_bitrate%,\\.[0-9]*\$,))
$if($eq(%_nAlbumType%,Classical),$set(_nFilePath,%_cClassical%/%_nYear% %_nANT% “\(”%_releasecomment% “\)” [%media% ] [%releasetype%]/))
$if($eq(%_nAlbumType%,Soundtrack),$set(_nFilePath,%_cSoundtrack%/%_nYear% %_nANT% “\(”%_releasecomment% “\)” [%media% ] [%releasetype%]/))
$if($eq(%_nAlbumType%,Other),$set(_nFilePath,%_cOther%/%_nYear% %_nANT% “\(”%_releasecomment% “\)” [%media% ] [%releasetype%]/))
$if($eq(%_nAlbumType%,Single),$set(_nFilePath,%_nInitial%/%_nPAAS%/%_cSingles%/%_nYear% %_nANT% “\(”%_releasecomment% “\)” [%media% ] [%releasetype%]/))
$if($eq(%_nAlbumType%,Standard),$if($eq($if2(%musicbrainz_albumartistid%,%_cVariousArtistID%),%_cVariousArtistID%),
    $set(_nFilePath,%_cVariousArtist%/%_nYear% %_nANT% “\(”%_releasecomment% “\)” [%media% ] [%releasetype%]/),
    $if($eq($if2(%musicbrainz_albumartistid%,%_cUnknownArtistID%),%_cUnknownArtistID%),
        $set(_nFilePath,%_cUnknownArtist%/%_nYear% %_nANT% “\(”%_releasecomment% “\)” [%media% ] [%releasetype%]/),
        $set(_nFilePath,%_nInitial%/%_nFAAPS%/%_nYear% %_nANT% “\(”%_releasecomment% “\)” [%media% ] [%releasetype%]/)
)))

I suggest changing this to:

########################################################################
#                                                                      #
#  Set File Path                                                       #
#                                                                      #
########################################################################
)
$noop(
$if($eq(%_nAlbumType%,Classical),$set(_nFilePath,%_cClassical%/%_nFAAPS%/%_nYear% %_nANT%/))
)
$if(%_releasecomment%,$set(_releasecomment, \(%_releasecomment%\)))
$set(_bitrate,$rreplace(%_bitrate%,\\.[0-9]*\$,))
$if($eq(%_nAlbumType%,Classical),$set(_nFilePath,%_cClassical%/%_nYear%%_nANT%%_releasecomment% [%media% ] [%releasetype%]/))
$if($eq(%_nAlbumType%,Soundtrack),$set(_nFilePath,%_cSoundtrack%/%_nYear% %_nANT%%_releasecomment% [%media% ] [%releasetype%]/))
$if($eq(%_nAlbumType%,Other),$set(_nFilePath,%_cOther%/%_nYear% %_nANT%%_releasecomment% [%media% ] [%releasetype%]/))
$if($eq(%_nAlbumType%,Single),$set(_nFilePath,%_nInitial%/%_nPAAS%/%_cSingles%/%_nYear% %_nANT%%_releasecomment% [%media% ] [%releasetype%]/))
$if($eq(%_nAlbumType%,Standard),$if($eq($if2(%musicbrainz_albumartistid%,%_cVariousArtistID%),%_cVariousArtistID%),
    $set(_nFilePath,%_cVariousArtist%/%_nYear% %_nANT%%_releasecomment% [%media% ] [%releasetype%]/),
    $if($eq($if2(%musicbrainz_albumartistid%,%_cUnknownArtistID%),%_cUnknownArtistID%),
        $set(_nFilePath,%_cUnknownArtist%/%_nYear% %_nANT%%_releasecomment% [%media% ] [%releasetype%]/),
        $set(_nFilePath,%_nInitial%/%_nFAAPS%/%_nYear% %_nANT%%_releasecomment% [%media% ] [%releasetype%]/)
)))

This sets the value of %_releasecomment% to enclose the comment within brackets and add a leading space before the first bracket if %_releasecomment% is not empty. If empty, it leaves it empty. This revised value of %_releasecomment% is then applied directly in your file path. Note that there is no space before the %_releasecomment% in each path definition because the space has been included when adding the brackets around the comment. This avoids having an extra space in the path if there is no comment.

The reason for the underscores was due to the use of the stylized quotes around the brackets in your script.

2 Likes

Not exactly. The double backslash before the period will be translated into a single backslash when passed to the regular expression processor, thus escaping the period. A period in a regular expression is a wildcard normally matching any character, but in our case we only want it to match a period which is why we need to escape it. The asterisk following [0-9] means match the values between the square brackets any number of times. The dollar sign at the end tells the regular expression to match at the end of the string. For more information, have a look at Regular Expressions on Wikipedia.

3 Likes

Thank you!! If I don’t have time today…I will try this out tomorrow.

@rdswift Thanks again for your help. I tested and it works. Now, I have noticed some data quality issues I’ll have to fix and also add some more programming to use Title Case for some of the fields.

2 Likes