Advanced-ish filenaming help needed(solved)

Hello!

I’m running into a bit of a snag, and it’s a little irritating to me; I’m hoping you experts might be able to help.

I’m currently using this script to rename and organize my files:

$replace($rreplace(
$if($eq(%albumartist%,Various Artists),[Various Artists],
$left($if2(%albumartistsort%,%artistsort%),1)
/
$left($rreplace($if2(%albumartistsort%,%artistsort%),; [^)]+,), 60))
/
$if(%date%,[$left(%date%,4)] )$left($replace(%album%,/,), 70)
$if($gt(%totaldiscs%,1),$if(%discnumber%, (Disc %discnumber%),),)
/
$left(%title%,120),[:?"_]+,), , )

It works like a charm…sort of. Bands like Ayreon and Aghast View are in folders “Ayreon” and “Aghast View”, while “The Beatles” are in “Beatles, The”. However, artists like Bryan Adams are being kicked over to “Adams, Bryan”. I’m sure it’s something simple I’m overlooking, any help is appreciated!

EDIT

Turns out, I just had to add a pair of $set tags to correct this:

$set(artistsort,$swapprefix(%artist%))
$set(albumartistsort,$swapprefix(%albumartist%))

Huge thanks to outsidecontext for the help!

You are using the sort name (albumartistsort or artistsort). “The Beatles” would be sorted in a catalogue under “Beatles, The”, and “Bryan Adams” under “Adams, Bryan”.

If you only want to “The” bands sorted in differently but want to keep the person names in “Firstname Lastname” order then use the normal albumartist or artist variables together with the $swapprefix function:

$swapprefix($if2(%albumartist%,%artist%))

See also the following discussions for more details:

3 Likes

That fixed it perfectly, thanks so much!

$set(artistsort,$swapprefix(%artist%))
$set(albumartistsort,$swapprefix(%albumartist%))
$replace($rreplace(
$if($eq(%albumartist%,Various Artists),
[Various Artists],
$left($if2(%artistsort%,%albumartistsort%),1)/$left($rreplace($if2(%albumartistsort%,%artistsort%),; [^)]+,), 60))
/
$if(%date%,[$left(%date%,4)] )$left($replace(%album%,/,), 70)
$if($gt(%totaldiscs%,1),$if(%discnumber%, (Disc %discnumber%),),)
/
$left(%title%,120),[:?"_]+,), , )

1 Like