[Question] Folder View of the new ReFacets in Foobar2000 2.0 beta 8

Support :snoo_biblethump:

I just tried out the new beta version and I'm having an issue with the folder view.

In my original layout, there are three columns. And the first two columns are for folders: first column displays all folders under my libraries; second columns displays the folders in the selected folder from first column. As shown in the following structure:

Folders | Subfolders | Album

After transferring to the new beta version, when I choose to group by folders, both columns only shows all the subfolders so that both are showing the same content.

In Preference -> Media Library -> ReFacets -> Views, there is an item Folder with Pattern value $directory(%path%). Can I change it back by modifing it?

Posted Sep 21, 2022, 1:47 AM UTC

56
ghstchldrn•

Yes, but it depends on consistency of your folder structure and how many folders deep the actual music files are, because the $directory() function is relative to the folder the music file is in.

Here is a folder map to demonstrate -

%path% =
M:\Music\Folder1\Folder2\Folder3\Track.MP3
           |       |       |
           |       |       $directory(%path%,1)
           |       $directory(%path%,2)
           $directory(%path%,3)

So if ALL your music files are exactly 3 folders deep, that makes it easy, just use the $directory numbers as above. (Add a second 'Folder' column in Preferences)

However if you have music files that are additional folders deep (perhaps using a "Disc 1" folder?), then there is the problem, because that folder is #1 as well and everything gets mixed up.

In that case you could use an $if function such as this (adjusting the $directory numbers for each column) -

$if($strcmp($left(%directory%,5),Disc ),$directory(%path%,3),$directory(%path%,2))

^ $if music file is in folder name that begins "Disc ", display level 3 folder, else display level 2 folder.

... but not so easy without knowing exactly the folder names and levels. And if music files are in several different levels, it becomes more difficult.

(This way, using an $if, is quite a backwards way of solving it. The other way would be to cut up the %path% using string functions and start at the top most folder, but that would take some work...)

2
ElectricalHeat3691OP•

Thank you so much!

My library is very complicated, mixed with different levels of folders, varying from one to three levels. In addition, sometimes a 3-level folder has tracks in level 2. So I need to sort it out.

But there is another problem: When I select a parent folder Folder 1 from first column, the second/third column doesn't show the subfolders in Folder 1, but only Folder 1 itself. And so in the third column, it shows all content in all subfolders when grouped by anything but folders.

1
ghstchldrn•

But there is another problem ...

Just in case I was not entirely clear: you need two (or more) "Folder" columns in Preferences with different patterns each. Folder 1 should have the highest set of $directory numbers -

Folder 1 -

$if($strcmp($left(%directory%,5),Disc ),$directory(%path%,3),$directory(%path%,2))

Folder 2 -

$if($strcmp($left(%directory%,5),Disc ),$directory(%path%,2),$directory(%path%,1))

However this $if way would not work anyway if tracks are in different levels with no common folder name (or tags) to test which level they should appear under.

1
Freeky•

I wanted to group by the first sibling folders inside my media library, and found this:

$directory(%path%,$sub($len(%path%),$len($replace(%path%,\,,|,,/,)),N))

Where N is the desired folder depth. To borrow u/ghstchldrn's example:

%path% =
M:\Music\Folder1\Folder2\Folder3\Track.MP3
     |     |       |       |
     |     |       |       $directory(%path%,$sub($len(%path%),$len($replace(%path%,\,,|,,/,)),4))
     |     |       $directory(%path%,$sub($len(%path%),$len($replace(%path%,\,,|,,/,)),3))
     |     $directory(%path%,$sub($len(%path%),$len($replace(%path%,\,,|,,/,)),2))
     $directory(%path%,$sub($len(%path%),$len($replace(%path%,\,,|,,/,)),1))

This works by counting the number of folders - by taking the difference of the length of %path% with and without folder separators - and using that to offset the argument to $directory().

2
ghstchldrn•

Well that is a much shorter way than the two others I just posted. Fantastic. It never ceases to amaze me how clever some people are with title formatting.

(Edit: I would point out though if you are monitoring folders on different levels, this would mix them up - same as my second example)

1
ghstchldrn•

I've come up with two alternate ways of getting folder names from the left / parent folder. It might depend though how many folders you are monitoring in Preferences > Media Library and/or how many levels deep they are.

First way tests for a folder named 'Music' (typically the monitored folder), and returns the next folder levels. This should work no matter what level the 'Music' folder is on (i.e. D:\Music or D:\Collection\Music) but would miss any other monitored folder (i.e D:\Podcasts).

Folder level 1 -

$puts(r,Music)$if($strcmp($directory(%path%,4),$get(r)),$directory(%path%,3),$if($strcmp($directory(%path%,3),$get(r)),$directory(%path%,2),$if($strcmp($directory(%path%,2),$get(r)),$directory(%path%,1),)))

Folder level 2 -

$puts(r,Music)$if($strcmp($directory(%path%,4),$get(r)),$directory(%path%,2),$if($strcmp($directory(%path%,3),$get(r)),$directory(%path%,1),))

^ The $puts function sets the folder name to test.

Second way tests for the first found $directory level (since I realized they return true/false like any tag) and returns a few below it (since apparently the drive letter also returns true). This way should work no matter what the folder is named, however it assumes the monitored folder is on the first level of the drive (i.e. D:\Music) and would return the wrong level otherwise.

Folder level 1 -

$if($directory(%path%,7),$directory(%path%,4),$if($directory(%path%,6),$directory(%path%,3),$if($directory(%path%,5),$directory(%path%,2),$if($directory(%path%,4),$directory(%path%,1),))))

Folder level 2 -

$if($directory(%path%,7),$directory(%path%,3),$if($directory(%path%,6),$directory(%path%,2),$if($directory(%path%,5),$directory(%path%,1),)))

(Both these ways are only testing for 3-4 folder levels, but could be more if needed if music files are deeper)

1