Filenaming Script

filenaming
picard
scripting
Tags: #<Tag:0x00007fe3d0085190> #<Tag:0x00007fe3d0085000> #<Tag:0x00007fe3d0084ec0>

#1

I suck at scripting to the point that it becomes frustrating. I had an ok script (never could figure out how to get rid of spaces for non-present data), but I reinstalled my OS and lost everything due to an oversite on my behalf. I was wondering if someone can help me turn this idea into a script. I would really appreciate it. You would be saving my sanity.

Save Location: F:\Music Library\

If Single Album Artist Single Disc

Folder: [album artist (Last, First)(name, prefix(i.e. the, a, an)]
Folder: [artist]
Folder: [album][country of origin(2 character abbreviation)][media][year][an identifier from first letters of [album artist][artist][album][country of origin][media][date fullISO standard or no spaces)][L for lossless or S for lossy]
Filename: [track number] - [song title]

Example: Throat, Bob/Bob Throat Lab Band/All the Plants Need Love/01 - Jeff Beck Stole My Stick

If Single Album Artist Multiple Discs

Folder: [album artist (last, first)(name, prefix(i.e. the, a, an)]
Folder: [artist]
Folder: [album][country of origin(2 character abbreviation)][media][year][an identifier from first letters of [album artist][artist][album][country of origin][media][date fullISO standard or no spaces)][L for lossless or S for lossy]
Folder: [disc number]([disc name] if available)
Filename: [track number] - [song title]

Example: Throat, Bob/Bob Throat Lab Band/All the Plants Need Love/Disc 01 (Subtitle if present)/01 - Jeff Beck Stole My Stick

If Various Artist (i.e. compilation) Single Disc

Folder: Various Artist
Folder: [album (name, prefix (i.e. the, a, an))][country of origin(2 character abbreviation)][media][year][an identifier “va” plus from first letters [album][country of origin][media][date full(ISO standard or no spaces)][L for lossless or S for lossy]
Filename: [track number] - [track artist] - [song title]

Example: Various Artists/Songs of the Deranged, The/01 - Bob Throat Lab Band - Jeff Beck Stole My Stick

If Various Artist (i.e. compilation) Multiple Discs

Folder: Various Artist
Folder: [album][country of origin(2 character abbreviation)][media][year][an identifier “va” plus from the first letters of[album][country of origin][media][date full (ISO standard or no spaces)][L for lossless or S for lossy]
Folder: [disc number]([disc name] if available)
Filename: [track number] - [track artist] - [song title]

Example: Various Artists/Songs of the Deranged, The/Disc 01 (Subtitle if present)/01 -Bob Throat Lab Band - Jeff Beck Stole My Stick

If a Standalone Track (i.e. not a member of an album or compilation)

Folder: Random Songs
Filename: [artist] - [title]


#2

Definitely happy to help, but it looks like you might be missing some of the information. If you did type it, maybe Discourse is treating it as comments somehow? Try surrounding it with \1 marks (the backtick under the tilde on a standard US keyboard) to have it render as code, which tends to be processed less. Otherwise, I do think I have a general idea of what you’re looking for in the folder hierarchy (though I wonder if you really do mean that the artist identifier should be within the artist folder, rather than the other way around) but wouldn’t complain about a more explicit description, and do need more info for the file name.

A slight enhancement I’ve made to my personal script that you may like as well, is that I treat albums containing only a single track as standalone recordings. Should I add that to yours? It doesn’t really matter if everything in your library is from a physical album, but it can come into play if you follow indie artists on Soundcloud or YouTube, for example; I also recently adapted it for someone who buys single tracks from albums, if that fits your library better.


#3

WovenTales, thanks for your offer to help. I can do college level algebra and acoustic formulas, but I am terrible at scripting (probably because most of the math I do works inside already known formulas). Sorry for the confusion with the initial post. I edited the post include the “variables.”

I like your single track idea. I do have Soundcloud and Bandcamp single tracks.

Again, much thanks and appreciation.


#4

Glad to! I find puzzling out how to turn a visual structure into computer-readable instructions rather fun.

Unfortunately, the split between what you’re calling “album artist” and “artist” isn’t as big as you’re hoping in our dataset: we’d probably consider “Bob Throat Lab Band” to be its own artist, and sort the album under that. It’s not universal – if the “Lab Band” was still the single person who’s just adopting the persona of a group, there’s a chance we’d put the name in the artist credits, which would mean the structure you’re hoping, but I wouldn’t count on it. To give you that capability, though, I’ve included a check for a custom variable: if the album would normally be sorted under the Lab Band name or something else you don’t want (check the Album Artist Sort Order in the bottom pane, and if that’s not there, the Album Artist, Artist Sort Order, and Artist fields, in that order, the latter of which are included for safety with incomplete tags), right click and add a new tag; in the dropdown at the top, ignore all the builtin names and type in artistfolder; finally, in the list of values (there’s an empty one at the top), write the folder you want to use, for example Throat, Bob. You’ll have to do that for every file in the album, but if you select the row with bold text and the CD icon before adding it, the new tag will automatically be shared across the entire thing. This is fully integrated in the Various Artists logic, so you can force an album to be treated as a compilation (or not) if you need to as well.

Likewise, the sortable name of the album isn’t one of the variables the database stores – I’ve complained about that a couple times on here – but I’ve put in a function that will do a mostly-decent job of sticking the prefixes at the end. If it doesn’t do something right, add a new tag like above, choose albumsort (it is in the list this time), and enter the proper form. Unfortunately, by default you won’t be able to see whether that’s necessary until after you save something; I’d recommend adding the first following line to a script in the “Scripting” page of the options so it’s more obvious. If you don’t like the Album Sort Order being included in every file, add the second as well which leaves only Album if the sort order’s not any different. If you do add the tagging script, I’d recommend replacing $swapprefix(%album%) in the main file naming script with just %album%, as leaving it in there causes hidden behaviour that might trip things up in the future.

$if($not(%albumsort%),$set(albumsort,$swapprefix(%album%)))
$if($eq(%albumsort%,%album%),$unset(albumsort))

Also, I made my best guess at the album identifiers, but I wouldn’t be at all surprised if it’s not exactly what you were wanting. If you can give a concrete example, I’ll be happy to fix that part for you – or, indeed, any bit of this that you were imagining formatted differently. Finally, I didn’t make adding the track artist be based on whether the album is a compilation or not, but rather on if it matches the artist for the rest of the album, so an artist who’s only featured on a single track will show up in the filename; we put them in the artist field rather than the title, but if you’d rather the latter, there’s a plugin (“Feat. Artists in Titles”) for that.

$noop(Provide a means of manually specifying the folder with %artistfolder%)
$set(_topartist,$if2(%artistfolder%,%albumartistsort%,%albumartist%,%artistsort%,%artist%,Unknown Artist))
$set(_displayartist,$if2(%albumartist%,%artist%,Unknown Artist))

$set(_isva,$if(%artistfolder%,
	$eq(%_topartist%,Various Artists),
	$or(
		$eq(%compilation%,1),
		$eq(%musicbrainz_albumartistid%,89ad4ac3-39f7-470e-963a-56509c546377)
	)
))

$noop(%albumsort% provides better control, but isn't automatically set)
$noop(If %albumsort% is populated via a script, replace `$swapprefix(%album%)` with just %album%)
$set(_albumfolder,$if2(%albumsort%,$swapprefix(%album%)))

$set(_displaymedium,$if2(%media%,Medium))

$noop(Guess at losslessness from the extension -- doesn't test MP4s)
$noop(Based on https://community.metabrainz.org/t/categorizing-lossless-music/258530/2)
$setmulti(_losslesstypes,flac;oggflac;ape;ofr;tak;wv;tta;wav)
$set(_islossless,$if($inmulti(%_losslesstypes%,%_extension%),L,S))

$noop(Take the first single letter or character from each field)
$set(_albumid,
	$if(%_isva%,
		VA,
		$left(%_topartist%,1)$left(%_displayartist%,1)
	)
	$left(%_albumfolder%,1)
	%releasecountry%
	$left(%_displaymedium%,1)
	%date%
	%_islossless%
)


$noop(Treat single-track albums as standalone recordings)
$noop(Note that this will not pull out single tracks that are said to be part of a larger album)
$noop(Neither will it recognize non-MusicBrainz albums as being proper albums /unless/ either %totaldiscs% and/or %totaltracks% has been set)
$noop(The track number is not checked for this purpose because I've come across single files on Soundcloud that have that field set for no reason)
$if($or($gt(%totaldiscs%,1),$gt(%totaltracks%,1)),
	%_topartist%/
	%_displayartist%/
	%_albumfolder%
		$noop(Some of the ifs aren't necessary, but they're an easy way of adding spaces)
		$if(%releasecountry%, %releasecountry%)
		$if(%media%, %media%)
		$if(%date%, $left(%date%,4))
		$if(%_albumid%, %_albumid%)/
	$if($or($gt(%totaldiscs%,1),%discsubtitle%),
		Disc $num(%discnumber%,2)$if(%discsubtitle%, %discsubtitle%)/
	)
	$num(%tracknumber%,2)
	$if($ne(%_displayartist%,%artist%), - %artist%)
	 - %title%
,
	Random Songs/
	%artist% - %title%
)

#5

Wow! Thanks. I appreciate the amount of work you put into the script. I’ll give it a try. It may work better than what I envisioned because you know Picard inside and out. I’ll let you know how it goes.

Much Thanks! :grinning:


#6

Thanks for the comments in the script. It gives me an idea of what is happening. :trophy:


#7

No problem! If you have any questions about how anything works, I’d be happy to go through it in more detail as well. Just looking at that again, I can definitely see it being difficult to parse.


#8

Thanks for the script, very inspirational.


#9

Could someone help me out with a script? I just want
Folder A-Z, #
Folder Artist
Folder album If not an album or various just be placed under artist folder.
file name Artist - Title

that’s it.

thank you for your help