File Naming / Moving help

Looking to structure my files like the below image. but I also want to include Extension in the final folder’s name.

So it would be [Year] Album Name [Extension]

And instead of like they are pictured, I would also like Various Artists to be under a separate top level folder called Various Artists and then a sub folder with the artists names. Example below
Various Artists
---- Last Name, First Name; Last Name2, First Name2; Last Name3, First Name3
------------[Year] Album Name [Extension]

Is this even possible?

This approaches what you’re looking for. As far as I know, there’s no way to tell Picard to get values from every track in the album (essentially, the files are renamed individually rather than as an entire release), and so I couldn’t add the artist subfolder to “Various Artists”. Likewise, if you have an album whose tracks have multiple extensions, it will be split between multiple folders – on the other hand, if you have the same album multiple times in different formats everything will work as you’d hope. Finally, you didn’t say how you wanted the individual tracks to be named, so I simply used ## - Title.___ where the number signs are the track number padded to two digits, and – along with the dash – aren’t included if the file doesn’t have a track number field (the album date is replaced with unknown if it’s not present).

$if($eq(%albumartist%,Various Artists),Various Artists,$left(%albumartist%,1)/%albumartistsort%)/
[$if(%date%,$left(%date%,4),unknown)] %album% [%_extension%]/
$if(%tracknumber%,$num(%tracknumber%,2) - )%title%

That does what I want. Thanks!

@WovenTales Nice template but I think I see one small problem as you’ve written it. The single letter directory is the first character of the %albumartist% tag when I think it should be the first letter of the %albumartistsort% tag.

One thing that I use here that @nullbyte might want to add is $if($gt(%totaldiscs%,1),%discnumber%-,) just before the track number if statement. This will put in the disc number if it’s part of a multi-disc album.

Another thing that I do here is put the artist information in the track filename if it is different from the album artist, by replacing %title% with %title%$if($ne(%musicbrainz_artistid%,%musicbrainz_albumartistid%), [%artist%],). Note that I use the %musicbrainz_artistid% and the %musicbrainz_albumartistid% tags for the comparison, to avoid issues with differences such as “Pretenders” versus “The Pretenders” (which both have the same ID). This works well for collections where the album artist is “Various Artists”. The results look like:

 Volume in drive X is Media Library
 Volume Serial Number is B771-1318
 Directory of X:\Music\Various Artists\Oh What a Feeling 3
2017-04-11  12:34    <DIR>          .
2017-04-11  12:35    <DIR>          ..
2017-04-11  12:02         2,857,780 1-01 Closer to the Heart [Rush].mp3
2017-04-11  12:02         3,462,834 1-02 Hey You [Bachman-Turner Overdrive].mp3
2017-04-11  12:02         2,095,094 1-03 Dreamboat Annie [Heart].mp3
2017-04-11  12:02         3,375,734 1-04 Sweet City Woman [Stampeders].mp3
2017-04-11  12:03         3,416,264 4-15 Bells [The Rankin Family].mp3
2017-04-11  12:03         3,401,586 4-16 Jimmy's Got a Girlfriend [The Wilkinsons].mp3
2017-04-11  12:03         3,564,251 4-17 Fall at Your Feet [Jesse Cook].mp3
2017-04-11  12:03         3,132,732 4-18 Consequence Free [Great Big Sea].mp3
2015-12-13  17:15            62,339 cover.jpg
              73 File(s)    273,103,158 bytes
               2 Dir(s)  5,047,198,019,584 bytes free

Then again, it’s all about personal preference. That’s the beauty of using the scripting in the Picard formatting template. Everybody can customize it to do pretty much whatever they like.


Thanks for the catches! Not quite sure how I forgot about the disc number, but that’s definitely important. And good call with comparing the artist and album artist IDs – I do the more basic version in my own library, but I have run into those issues with slightly different aliases.

EDIT: Here’s the line I wound up with, to replace the %artist% in your second function with just the tail if it’s in the pattern %albumartist% feat. Someone (becomes feat. Someone). It will probably need a bit of tweaking for anyone else since I’m wrapping my entire filename in a $rreplace(...) that removes duplicate whitespace, and it runs into the same problem if %artist% or %albumartist% is using a custom artist credit, but it’s not a bad start. And, yeah, I know the $startswith(...) function exists; it was acting like it was always true for some reason.


So what then would be the final code?

$if($eq(%albumartist%,Various Artists),Various Artists,$left(%albumartistsort%,1)/%albumartistsort%)/
[$if(%date%,$left(%date%,4),unknown)] %album% [%_extension%]/
$if(%tracknumber%,$if($gt(%totaldiscs%,1),%discnumber%-)$num(%tracknumber%,2) - )%title%$if($ne(%musicbrainz_artistid%,%musicbrainz_albumartistid%), [%artist%])

I’ve left out my edit to the [Track artist] in the filename since that’s more for situations where the artist is appended without any brackets; I just posted it in case anyone else might be inspired by it.

1 Like

Is it possible to also sort by Match %? So complete matches / gold discs would go in one top level folder and partial matches in another.

----------------Artist Name
----------------------[Year] Album / Release [Extension]
-------------------------------------------------------------------- ## - Title.___

----------------Artist Name
----------------------[Year] Album / Release [Extension]
-------------------------------------------------------------------- ## - Title.___

I feel like there’s a more direct way of getting that info, but I’m not seeing it in the documentation. If anyone else knows it, then feel free to post; otherwise, the line below is close to what you’re looking for – if one track has multiple attached files, the album can still be marked as “Complete” despite the disc not being gold, and I’m not sure how it will handle albums that aren’t on MusicBrainz (Picard keeps freezing when I try to test it). If you’re all right with those idiosyncrasies, add this line before the other three I gave you:

$if($eq($matchedtracks( ),%_totalalbumtracks%),Complete,Partial)/
1 Like

There is a $is_complete() function. It basically does the same as your check with $eq($matchedtracks( ),%_totalalbumtracks%), but is exactly the same as the gold disc check. It takes into account settings to ignore special tracks (e.g. you can set Picard to ignore video tracks when determining completeness).

It is missing from the documentation for no particular reason. We should fix that :slight_smile:

1 Like

To add to this. What about adding a top level folder for complete but no matches in the database?

So Complete, Partial, No Match would be the folders.

Thanks for all your help btw

Sweet! I’ve been thinking about doing something like that, but never really got anywhere. This is great and will save a lot of time, and give me a starting point for my tweaks. Thanks.

For that, you’ll probably be looking at checking the album title against the “Non-album tracks” option (under “Metadata”), but I’m unfortunately probably not going to be able to help write it – when I add one of my local playlist “albums”, Picard freezes before I can figure out what the fields look like. If I do get that sorted out soon enough, I’ll see what I can get together for you, but it’s going to take a bit more time to look into than I’m wanting to give it at the moment so I’m not going to promise anything.

1 Like