Yeah. Not sure what happened to it either, but, using the example of Freight Train,
%albumartist% contains "Alan Jackson" (the name under the title at the top of the page) for everything in the release, and while
%artist% is the same for most of the tracks (the name in the "Artist" column of the tracklist), "Till the End" has an artist of "Alan Jackson feat. Lee Ann Womack". Since your script is only using the second, it doesn't care what's in
%albumartist% and is perfectly happy to pull that one track out from the rest of the others, because it is different from the others.
I wouldn't do a straight replacement, because that will wind up having trouble with what we call standalone recordings -- roughly, songs that aren't part of an album. Instead, I recommend the following line:
$if2(%albumartist%,%artist%,Unknown Artist)/%album%/%artist% - %title%
$if2 part says "take the first one of these that's not empty", which will be
%albumartist% for the most part, but will still fall back to
%artist% for those rare weird files. If even that is empty -- essentially, will only happen if the file has no real tags and you don't know anything about it beyond the fact you like it -- it creates an "Unknown Artists" folder to stick it in just to clean things up that little bit more.
Another question I have is whether you mean to not have the track numbers; do you like the file being named
Alan Jackson - After 17.mp3 or would you rather
03 - Alan Jackson - After 17.mp3? Not an issue either way since any music library program will see the
03 in the tags and put it third in the album, but adding that to the file name brings that organization to the file browser. If you do like the second, use this line instead:
$if2(%albumartist%,%artist%,Unknown Artist)/%album%/$num(%tracknumber%,2) - %artist% - %title%
You'll probably need to load and save your entire library back through Picard (in manageable chunks) if you do add the track number to the file rather than just the misfiled songs the first script requires, so take that into consideration when deciding which to use.