Conditional Naming Help

Hi guys,

I am not a programmer, trying my best here follow some tutorials and figure this out… I am almost there.
I like to name my files with (Studio - … (Live - … (Compilation -… In the end I get results like, supose Anthrax albums:

(Compilation - 2004) The Greater of Two Evils
(Live - 1994) The Island Years
(Studio - 1987) Fistul of Metal

My full naming script is:

$if($in(%releasetype%,album), $set(_isAlbum,1) )
$if($in(%releasetype%,album/live), $set(_isLive,1) )
$if($in(%releasetype%,single), $set(_isSingle,1) )
$if($in(%releasetype%,ep), $set(_isEP,1) )
$if($in(%releasetype%,album/compilation), $set(_isArtistCompil,1) )

$if($is_complete(),Complete Albums,Missing Tracks)/

%albumartist%/(

$if($eq(%_isAlbum%,1),Studio)

$if($eq(%_isLive%,1),Live)

$if($eq(%_isSingle%,1),Single)

$if($eq(%_isEP%,1),EP)

$if($eq(%_isArtistComplil%,1),Compilation)

- $year(%date%,4)) %album%/

(%album% - $year(%date%,4)) $num(%tracknumber%,2) - %title%

Seems bit messy pasting, here a SShot:
Untitled-8

Ok, I keep getting on (Studio - …

Help?

First off, I’m assuming that you’re doing the renaming based on the metadata from MusicBrainz (in other words after matching your files to tracks in the right-hand pane) rather than metadata existing in the files. That said, try the following:

$if($eq(%_primaryreleasetype%,album),$set(_type,Studio))
$if($eq(%_primaryreleasetype%,single),$set(_type,Single))
$if($eq(%_primaryreleasetype%,ep),$set(_type,EP))
$if($in(%_secondaryreleasetype%,live),$set(_type,Live))
$if($in(%_secondaryreleasetype%,compilation),$set(_type,Compilation))
$set(_type,$if2(%_type%,Unknown))
$set(_year,$if2($year(%date%),0000))

$if($is_complete(),Complete Albums,Missing Tracks)/
%albumartist%/\(%_type% - %_year%\) %album%/
\(%album% - %_year%\) $num(%tracknumber%,2) - %title%

Note that I’ve used the %_primaryreleasetype% and %_secondaryreleasetype% variables for more specific checking, and escaped the opening and closing brackets that you want to appear in the output. I’ve also included a default type of Unknown in case there were no matches and a default year of 0000 if the %date% tag is empty. Finally, I’ve taken the liberty of refactoring a little to reduce the number of interim variables.

Part of the problem with your existing code was that “album/live” and “album/compilation” are not valid entries in the `%releasetype% variable and would therefore always fail the checks. The reason that the date portion was missing is because the enclosing brackets were not escaped, thus Picard tried to interpret the content between the brackets as code.

Please let us know if this does what you are looking for.

6 Likes

As a tip, you can put the Picard script in a code block and the forum here will show it with syntax highlighting. See the description at

I took the freedom to edit your post to use this instead of the quote.

2 Likes