How would I go about flipping the Various Artist folder with the Album title?

Here’s a pic of what I’m looking at Various%20Artists

What I want to happen is that when a Various Artists album is found, I want a folder created for that album, but I want the name of that folder flopped from how it appears here. In this example, I would like the folder to be named “Dancehall Baptism Chapter One - Various Artists”

If you can post your current naming script, I can show you how to modify it to do what you ask. That way I’m not guessing on how it’s set up (and screw something up in providing a replacement).

1 Like

At this point, I have only the simplest script as a start. FragaGeddon was kind enough to post his script with modifying variables, but in working with it, it seems to be more than I need, and every time I “fix” something, it screws it up with another type of album. I’m looking to address multiple needs, but was trying to tackle them one by one. Here’s essentially what I’m trying to accomplish:

First things first, I want Picard to sort single-artist discs:
Example: Artist = Joe Smith Album Title = Brother
Track# should be 2 digits (01-09, 10-99)
Track title should follow the track #

I would like all albums to be initially sorted as follows

Main Music Folder / Joe Smith - Brother / 01 - First Song

If there are any additional artists, I want them to be identified on the track title ONLY,
and not to be used to further sort into additional folders (this would include any "Feat, “featuring”, “with”, etc)

I’ve been able to do a simple tagging with this:

$if2(%albumartist%,%artist%) - %album%/$num(%tracknumber%,2) - %title%

For the most part, that seems to work, although as I add more albums to my “sandbox” to test this out, I’m running across underscores being added, multiple discs being split out and creating unwanted filenaming issues, and it won’t handle any Various Artist albums.

If the album is a Various Artists album (such as a soundtrack or a compilation) I would
like to see them sorted as follows (using the album “Now! Volume 26” as an example)

Main Music Folder / Now! Volume 26 - Various Artists / 01 - First Song - Artist Name

Lastly, if any of the above albums were to span multiple discs, I would want them to be
sorted as follows:

Main Music Folder / Joe Smith - Brother (Disc 01) / 01 - First Song
Main Music Folder / Joe Smith - Brother (Disc 02) / 01 - First Song

Main Music Folder / Now! Volume 26 - Various Artists (Disc 01) / 01 - First Song
Main Music Folder / Now! Volume 26 - Various Artists (Disc 02) / 01 - First Song

Give this a try. I’ve tried to divide it up into sections to make it a bit easier to see what I’m doing. The script first sets some constants, then initializes its working variables, builds the naming elements, and finally assembles the naming elements based on the “Various Artists” criterion. It’s a lot more verbose than it needs to be in order to clarify and identify which lines need to be modified to meet your specific situation. If you have any questions, just ask.

$noop(
#######################################################################
#
#  Basic Constants
#
#######################################################################
)
$set(_kUnknownArtistID,125ec42a-7229-4250-afc5-e057484327fe)
$set(_kVariousArtistID,89ad4ac3-39f7-470e-963a-56509c546377)
$set(_kUnknownArtist,[Unknown Artist])
$set(_kVariousArtist,[Various Artists])
$set(_kUnknownAlbum,[Unknown Album])
$set(_kNoTitle,[Unknown Title])


$noop(
#######################################################################
#
#  Initialize Working Variables
#
#######################################################################
)
$set(_wTotalDiscs,$if2(%totaldiscs%,1))
$set(_wDiscNum,$if2(%discnumber%,1))
$set(_wAlbumArtistID,$if2(%musicbrainz_albumartistid%,%_kUnKnownArtistID%))
$set(_wAlbumArtist,$if2(%albumartist%,%artist%,%_kUnknownArtist%))
$set(_wAlbum,$if2(%album%,%_kUnknownAlbum%))
$set(_wTrackNum,$if2(%tracknumber%,1))
$set(_wArtist,$if2(%artist%,%albumartist%,%_kUnknownArtist%))


$noop(
#######################################################################
#
#  Build naming elements to use.
#
#######################################################################
)
$set(_fnDiscNum,$if($gt(%_wTotalDiscs%,1), \(Disc $num(%_wDiscNum%,2)\),))
$set(_fnTrackNum,$num(%_wTrackNum%,2))
$set(_fnAlbumArtist,%_wAlbumArtist%)
$set(_fnTrackTitle,$if2(%title%,%_kNoTitle%))
$set(_fnTrackArtist,$if($eq(%_wAlbumArtist%,%_wArtist%),, [%_wArtist%]))
$set(_fnAlbum,%_wAlbum%)


$noop(
#######################################################################
#
#  Assemble the naming elements to produce the output path and file name to use.
#
#######################################################################
)
$set(_OutputPath,$if($eq(%_wAlbumArtistID%,%_kVariousArtistID%),%_fnAlbum% - Various Artists%_fnDiscNum%,%_fnAlbumArtist% - %_fnAlbum%%_fnDiscNum%))
$set(_OutputFile,%_fnTrackNum% - %_fnTrackTitle%%_fnTrackArtist%)

%_OutputPath%/%_OutputFile%


$noop(
#######################################################################
#
#  End of script.
#
#######################################################################
)

One final thing… There is a plugin to remove the “featured artist” information from the database track titles, which I strongly suggest using with this script. Normally it shouldn’t matter, but you may encounter some tracks where that information has been included in the track title rather than the artist credits.

Holy cow that’s a lot to take in!

I ran it on some test files - for the single-disc Various Artist types of folders, the output is perfect. When it comes to the multi-disc folders, a second “(disc X)” seems to be put in. In the attached picture, the part noted in red is the undesireable result. Is there a way to remove that?

The only other issue is the resulting underscores (noted in blue). For the Alabama disc, the underscore was caused by a colon “:” and in the case of the Andy Hunter discs, for some reason, there’s a degree symbol at the end of his name, causing the underscore.

When viewing the individual tracks, the underscores are created as well. I haven’t had a chance to look closer as to what it is that results in creating the underscores.

I very much appreciate the script above, btw. It’s light years ahead of what little I am understanding!

Underscores%20And%20Xtra%20Discs

I’m guessing that you have the Classic Disc Numbers plugin enabled. If so, try disabling it. If not, I’ll have to come up with a different theory. :slight_smile:

The underscores are because Picard is replacing characters that can’t be used in file or directory naming on your system. We shouldn’t stop the replacement (and I’m not sure we could), but we can remove the underscores if you like by changing the last line of the script from

%_OutputPath%/%_OutputFile%

to

$replace(%_OutputPath%/%_OutputFile%,_,)

The problem with this is that sometimes words are separated by a special character with no spaces, and when the resulting underscore is removed the words run together. For example, “one:two” would be changed by Picard to “one_two” and subsequently changed by our script to “onetwo”. It’s likely a rare enough occurrence that it’s not worth worrying about.

That was the exact problem - disabling that plugin gave the desired results.

This resulted in removing the underscores from the track name only where there was a backslash (Medley: First Song / Second Song / Third song ended up Medley_ First Song Second Song Third Song), but any other odd characters (?, :, !, the degree symbol, etc) still resulted in an underscore replacing it, both in the folder name and the file name.

At least we’re getting closer. :slight_smile: What is the operating system on your computer? I’m on Windows 7 here. I’m pretty sure that I can put something together using regular expressions, but have the feeling that there’s an easier way that I’m not seeing at the moment. What happens if you check the Replace non-ASCII characters checkbox on the File Naming page under Options?

I’m running Linux. The box was checked for Replace non-ASCII characters. I unchecked it and gave it a try, no good, so I checked the box again. I did notice the Windows compatibility option directly below that, and unchecking that results in seeing the : and ? in folders and filenames, but the degree symbol as shown in the pic above (Andy Hunter* - asterisk because I can’t create the degree symbol) results in an underscore. Backslashes are removed in filenames.

That’s likely as close as you’re going to get without a special replacement command listing all the symbols to be replaced. I suspect that the situation may be rare enough that it might be easiest to just manually rename that one directory.

Just on a lark, perhaps try changing the last line of the script from

$replace(%_OutputPath%/%_OutputFile%,_,)

to

$rreplace(%_OutputPath%/%_OutputFile%,[_°],)

and see if that works for you. If it does, all you should need to do when you encounter something like that in the future is copy the offending symbol (I copied it from my web browser’s screen) and paste it into the script along with the other symbols in the square brackets.

That worked! Yeah, I agree that this would be a super-rare situation. Bon Jovi’s 7800* Fahrenheit is the only other one that comes to mind.

I really appreciate all your hard work :+1: