I have an incredibly simple goal and've tried a variety of expressions seen throughout the forum and though I've had luck with other such endeavors, having no luck this time so asking.
I simply want to create a custom Library Field, let's call it
Album Artist (by directory)which is always generated from the name of corresponding folder at a certain position from start / root of library file path, not from file on backwards toward root as the number of subfolders can vary that way whereas position of targeted folder is constant from the start of root.
Hence, if my library is gathered by album artist on a disk named
MC_Discin a folder name
MC_Musicthe targeted directory to populate this field would be at fourth position below, as represented by an
*, with path shown in manner MediaCenter displays same path to Library in macOS.
Volumes/MC_Disc/MC_Music/
*/AlbumName/SongTitle.ext
For example, all of the following—
Volumes/MC_Disc/MC_Music/Miles Davis/Milestones/Two Bass Hit.flac
Volumes/MC_Disc/MC_Music/Miles Davis/Sorcerer/Limbo.flac
Volumes/MC_Disc/MC_Music/Miles Davis/Live/Agharta/CD1/Prelude.m4a
Volumes/MC_Disc/MC_Music/Miles Davis/Circle in the Round/CD2/Side Car I.ogg
would populate the custom
Album Artist (by directory)field with
Miles Davis
This seems very obvious so not sure how everything I've tried yet is failing in one way or another. In addition to simpler attempts, using this Windows solution and changing the back slashes to forward for macOS didn't work; turns out I had to leave in the Windows backwards slashes for some reason.
https://yabb.jriver.com/interact/index.php?topic=59233.0So, working from that I can get
=ListItem([Filename (\Volumes\MC_Disc\MC_Music\)],Math(ListCount([Filename (\Volumes\MC_Disc\MC_Music\)],\)-2),\)
to fill the custom field with "MC_Music" but that's not what I need; I need "Miles Davis" applied to field for files in
Volumes/MC_Disc/MC_Music/Miles Davis/
"Meredith Monk" for files in
Volumes/MC_Disc/MC_Music/Meredith Monk/
and so on.
Looks like I need to know the wildcard for final/fourth directory, and nothing I've tried works. And really it should be and probably is simpler than all that.
Thanks