Skip to main content
Topic: Facets and alphabetical grouping (Read 357 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Facets and alphabetical grouping

I'm trying to setup fb2k to behave like many players do "out of the box", with the ability to group tracks alphabetically. It's for someone who's extremely computer illiterate. I'm using Facets columns, but I'm wondering if anyone can suggest a less convoluted or better syntax for doing this. It works, but I'm still curious. Thinking about it, I'm not even sure I understand why the final line achieves the desired result, but it does.

The syntax I'm using for the alphabetical column is below. The attached screenshot shows the result. The second column displays %title%. I've split the syntax into multiple lines so it's easy to follow.

Thanks.

$puts(TITLE,$replace(%title%,'',,'(',))
$puts(NUM,
$ifequal($strchr($left($get(TITLE),1),0),1,0-9,)
$ifequal($strchr($left($get(TITLE),1),1),1,0-9,)
$ifequal($strchr($left($get(TITLE),1),2),1,0-9,)
$ifequal($strchr($left($get(TITLE),1),3),1,0-9,)
$ifequal($strchr($left($get(TITLE),1),4),1,0-9,)
$ifequal($strchr($left($get(TITLE),1),5),1,0-9,)
$ifequal($strchr($left($get(TITLE),1),6),1,0-9,)
$ifequal($strchr($left($get(TITLE),1),7),1,0-9,)
$ifequal($strchr($left($get(TITLE),1),8),1,0-9,)
$ifequal($strchr($left($get(TITLE),1),9),1,0-9,))
$ifequal($len($get(NUM)),3,$get(NUM),$left($get(TITLE),1))


PS. For some reason if I use 0 - 9 above rather than 0-9 it won't work. That might be a Facets quirk, but if anybody knows why....
PPS. Is there a way to compare strings directly rather than by their length as I have for the last line above?
Something like $if(%directoryname%,"My Music Folder",then, else)

Cheers.

Re: Facets and alphabetical grouping

Reply #1
I wanted something similar, but used the “$replace()” function instead:
Code: [Select]
$replace($left($caps($stripprefix([%album artist%])),1),0,#,1,#,2,#,3,#,4,#,5,#,6,#,7,#,8,#,9,#)
What this does is remove certain prefixes (e.g. “The”), truncates the artist’s name to the first letter, and then replaces any numbers with the “#” symbol.

If you’d prefer to stick with “0-9”, then you can use the following instead:
Code: [Select]
$replace($left($caps($stripprefix([%album artist%])),1),0,0-9,1,0-9,2,0-9,3,0-9,4,0-9,5,0-9,6,0-9,7,0-9,8,0-9,9,0-9)
If you have any artists that begin with accented letters, you can just add them to the replace function to have them filtered to the non-accented letter:
Code: [Select]
$replace($left($caps($stripprefix([%album artist%])),1),0,#,1,#,2,#,3,#,4,#,5,#,6,#,7,#,8,#,9,#,Ó,O,Ü,U)

Re: Facets and alphabetical grouping

Reply #2
beardgoggles,

Thank you. That's much simpler (I'm grouping by title, but it's the same idea).

I eventually worked out I still had to clear the junk from the beginning of the title first, as I had before (titles that begin with an opening bracket or single quote, and removing spaces etc) and I hadn't thought about using $caps or $stripprefix. What I've ended up with does the same job, only better, and it's far less convoluted.

Thanks again!

Edit: For some reason $stripprefix doesn't want to work unless it's being used directly with the %title% field, so I've had to move it up to the $puts line. Maybe I'm missing something...

Code: [Select]
$puts(TITLE,$replace($stripprefix(%title%),!,,#,,'',, ,,'(',))
$replace($left($caps($get(TITLE)),1),0,0 - 9,1,0 - 9,2,0 - 9,3,0 - 9,4,0 - 9,5,0 - 9,6,0 - 9,7,0 - 9,8,0 - 9,9,0 - 9)

Re: Facets and alphabetical grouping

Reply #3
(I'm grouping by title, but it's the same idea).
Sorry – I noticed that you were after title rather than artist after posting! 😖

Edit: For some reason $stripprefix doesn't want to work unless it's being used directly with the %title% field, so I've had to move it up to the $puts line. Maybe I'm missing something...
It could have been a missing bracket or comma, as I was able to wrap a $replace function inside $stripprefix successfully.

Also, if you want to have the code in a single line without needing a $puts function, try the following and see if it works for you:
Code: [Select]
$replace($left($caps($stripprefix($replace(%title%,-,,!,,¡,,¿,,#,,'',,",,“,,‘,,’,, ,,'(',,'[',,'$',,*,,.,))),1),0,0 - 9,1,0 - 9,2,0 - 9,3,0 - 9,4,0 - 9,5,0 - 9,6,0 - 9,7,0 - 9,8,0 - 9,9,0 - 9)
(The above example also adds in some characters that I have in track titles in my foobar2000 library.)

Re: Facets and alphabetical grouping

Reply #4
beardgoggles,

Thanks again!

I tried the syntax from your last post but for some reason $stripprefix won't work that way for me. At least not how I expect it to. Here's what happens using your above method. You can see from the first screenshot, everything beginning with "The" is to be found under "T" using your recent syntax. When I use the $puts line and move $stripprefix to there, it works like the second screenshot. I've tried it with and without the Facets option to ignore the leading "The" when sorting, but it made no difference. I've been meaning to rename everything beginning with "The" anyway. Now I might find the motivation (renaming "The Strangest Thing" to "Strangest Thing, The" etc). I've done that for many tracks, but there's plenty to do. Gremlins....
Later on I might try again on a fresh fb2k install without most of the additional plugins to see if anything changes. It's also odd that using "0 - 9" as a folder wouldn't work for my previous method (nothing would display) so I had to use "0-9" instead. Using your method, either of them work.

Cheers.

Edit: I'm adding the following info for anyone else who might stumble across this thread.
One particular setup I'm configuring fb2k for has folders for some albums, and a large main folder with mixed artists and titles. I've finally worked out how to use alphabetical sorting only for the "Mixed" folder. It relates to my question in the opening post regarding comparing strings. Either I wasn't using $strcmp correctly, or there were more gremlins when I tried it originally, but the following only creates an alphabetical column for a folder called "Mixed". The rest of the folders are simply grouped by folder name. To make it work sensibly I've used two columns for the first Facets pane, with the first column simply displaying "Folder" (a Facets default column). The end result is the third screenshot.

I've split the lines again so it's easier to follow.

Code: [Select]
$if($strcmp(%directoryname%,Mixed),
$puts(TITLE,$replace($stripprefix(%title%),!,,#,,'',, ,,'(',))
$replace($left($caps($get(TITLE)),1),0,0 - 9,1,0 - 9,2,0 - 9,3,0 - 9,4,0 - 9,5,0 - 9,6,0 - 9,7,0 - 9,8,0 - 9,9,0 - 9),
%directoryname%)

Re: Facets and alphabetical grouping

Reply #5
Hi there,

My (unsolicited) thoughts - I would not be renaming any of TITLE fields, that is the job of title formatting and why the likes of $stripprefix / $swapprefix exist in the first place. Just get the code right and save yourself the unnecessary re-tagging work.

It's also odd that using "0 - 9" as a folder wouldn't work for my previous method (nothing would display) so I had to use "0-9" instead.
(Although you are not using this method anymore...)

Probably because $ifequal and $len is asking how many characters -

Quote
$ifequal($len($get(NUM)),3, ...

"0-9" = 3 characters, "0 - 9" = 5 characters.

Cheers

Re: Facets and alphabetical grouping

Reply #6
My (unsolicited) thoughts - I would not be renaming any of TITLE fields, that is the job of title formatting and why the likes of $stripprefix / $swapprefix exist in the first place. Just get the code right and save yourself the unnecessary re-tagging work.

I think I started doing it because my portable MP3 player doesn't do any title formatting.

Probably because $ifequal and $len is asking how many characters -

I checked and it seems you're correct. I thought I'd tested it properly, but maybe that's what I did silly.

Thanks.

Re: Facets and alphabetical grouping

Reply #7
You can also use pipes for heirarchical formatting, e.g.

<<<$caps($cut($stripprefix(%title%),1))>>>|$stripprefix(%title%)

Re: Facets and alphabetical grouping

Reply #8
mjm716,
Thanks for that, but unfortunately I couldn't get it to work as I needed it to in this context.

For anyone who's interested though, I worked out how to reduce alphabetical sorting for a single folder to a single Facets pane, rather than using dual columns in order to keep the folders sorted properly as I had for the example in my previous post.

Code: [Select]
$if($strcmp(%directoryname%,Mixed),
$puts(TITLE,$replace($stripprefix(%title%),!,,#,,'',, ,,'(',))
Mixed    $replace($left($caps($get(TITLE)),1),0,0 - 9,1,0 - 9,2,0 - 9,3,0 - 9,4,0 - 9,5,0 - 9,6,0 - 9,7,0 - 9,8,0 - 9,9,0 - 9),
%directoryname%)

 
SimplePortal 1.0.0 RC1 © 2008-2019