Skip to main content
Topic: Group by 'Folder' (Playlist View) (Read 391 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Group by 'Folder' (Playlist View)

Hi there!

Facets has a very useful column called 'Folder' that I tried to reproduce without success in the 'Playlist View'.

I tried $directory_path (% path%) and %directoryname%, but the results are not the same as obtained by Facets 'Folder'.

If someone could help me with the correct variable I would be immensely grateful.

Re: Group by 'Folder' (Playlist View)

Reply #1
It looks like Facets "Folder" (I don't normally use the folder column) displays the first folder in the path after the media library folder.
So if you had a main folder for your media library called "My Music" and the path was
My Music/Some Artist/Some Album/Some Song
Folder displays Some Artist, whereas %directoryname% displays Some Album.

Without re-arranging my music library, that seems to be what "Folder" is doing. If I'm correct, is that what you're wanting to emulate? If so, something like this seems to do the trick. It assumes your main music folder is called "My Music" so obviously you need to edit it accordingly.
It checks if 4 levels up the file path is your main music folder "$directory(%path%, 4)", and if it is, it returns the next folder level down "$directory(%path%, 3)". If not, it checks three levels up and returns the next folder down etc. I only gave it a quick test, but it seems to work. You might have to add more levels if you have lots of sub-folders.

$if($strcmp($directory(%path%, 4),My Music),$directory(%path%, 3),$if($strcmp($directory(%path%, 3),My Music),$directory(%path%, 2),$if($strcmp($directory(%path%, 2),My Music),$directory(%path%, 1),%directoryname%)))

Re: Group by 'Folder' (Playlist View)

Reply #2
@yetanotherid

I couldn't develop an efficient solution like yours! However, my library contains several different directories, it is not a fixed thing like "My Music". The option that 'Facets' presents fits well in any directory. Still, your solution is very useful, thanks for your dedication!

Re: Group by 'Folder' (Playlist View)

Reply #3
@Johnny Blade
You can chain several of them together. As long as the folder you want to display is always one down from the specified directory the following will work. Or it could be changed to display the specified directory if it exists etc. I'm still not 100% sure what you want displayed for your folder structure. There'll be a rule or two though. The directory you want to use as the "root" directory can't have a directory above it that includes or has the same name. Here's a sample for a single file path. The "root" directory is called Directory1.

$if($strcmp($directory(%path%,4),DIRECTORY1),$directory(%path%,3),$if($strcmp($directory(%path%,3),DIRECTORY1),$directory(%path%,2),$if($strcmp($directory(%path%,2),DIRECTORY1),$directory(%path%,1),$if($strcmp($directory(%path%,1),DIRECTORY1),$directory(%path%,1),))))

It's the same as before, except it doesn't display anything if the specified directory doesn't exist. If it does, the next directory down is returned. You can chain several of them together, but without line-breaks between them when you enter it all as column syntax. ie for two folders, Directory1 and Directory2.

$if($strcmp($directory(%path%,4),DIRECTORY1),$directory(%path%,3),$if($strcmp($directory(%path%,3),DIRECTORY1),$directory(%path%,2),$if($strcmp($directory(%path%,2),DIRECTORY1),$directory(%path%,1),$if($strcmp($directory(%path%,1),DIRECTORY1),$directory(%path%,1),))))$if($strcmp($directory(%path%,4),DIRECTORY2),$directory(%path%,3),$if($strcmp($directory(%path%,3),DIRECTORY2),$directory(%path%,2),$if($strcmp($directory(%path%,2),DIRECTORY2),$directory(%path%,1),$if($strcmp($directory(%path%,1),DIRECTORY2),$directory(%path%,1),))))

That would only display a folder for files within the specified directories, but that's the sort of the Facets does, meaning it can only display a folder for files in your media library, but you could add syntax to display a directory for files that aren't in those directories, or display something like "not in library", but if you're interested in trying the above, see if it looks like it'll work and if there's any gremlins to iron out I haven't thought of, and hopefully they can be avoided.
I've just joined them together, but with a slight change you could do it so if Directory1 exists in the path, it doesn't look for Directory2. That sort of thing.

PS. If the specified directory contains an apostrophe, you need to use two of them.
ie Jonny''s Music rather than Johnny's Music.

Re: Group by 'Folder' (Playlist View)

Reply #4
@yetanotherid

You left me speechless...

I fully understood the scope of the solutions presented! I realize that the way you developed them, everything is covered properly!

It now remains for me to carefully put into practice this true class that you have taught here and to thank you very respectfully for your immense patience and very fruitful dedication!

I've never seen a forum like this and people like you enrich any experience!

My sincere thanks!

Re: Group by 'Folder' (Playlist View)

Reply #5
@Johnny Blade, you're welcome.
Actually, I got something wrong. It shouldn't matter if the specified directory is a sub-directory of a folder with the same text in it's name, they just wouldn't be able to have exactly the same name. I think I was originally using a different method where it did matter and forgot I changed it.


Re: Group by 'Folder' (Playlist View)

Reply #6
OK! It works very fine here now. And it has shown a behavior similar to Facets 'Folder' - just as I wished!

 
SimplePortal 1.0.0 RC1 © 2008-2020