Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Scripting folder list (Read 1540 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Scripting folder list

I have some code that sorts/displays the play lists in a special way.  One problem is dealing with directories that have only one entry:

Album_name (1)
    Song_name

I would like it to just display

Song_name

here is the specific code:


$puts(mainDir,Music)
$puts(drive,$substr(%path%,0,1))
$puts(pathUp1,$substr(%path%,4,999))
$puts(pathUp2,$substr($get(pathUp1),$add($strchr($get(pathUp1),\),1),999))
$puts(root,$substr($get(pathUp1),0,$add($strchr($get(pathUp1),\),1)))
$puts(path1,$substr($get(pathUp1),0,$add($strchr($get(pathUp1),\),-1)))
$puts(dir,$substr(%path%,10,999))
$puts(pos,$add($strchr($get(dir),\),1))
$if($stricmp($get(path1),$get(mainDir)),
$replace($get(pathUp2),\,|),
$replace($get(pathUp1),\,|))


Basically the last two lines need a fixed so they do not pipe for paths that contain only one audio file.

In fact, I would like the above code to group. 2nd to last line is for stuff like

0 (2)
1 (3)
...
A (4)
B (1)
C (1)
....

which I would like to turn into

0-9 (15)
A-C (6)

etc.... The solution should be chosen optimally as to reduce the listing size(else basically end up with 30+ elements in the list even though most just have 1 child). To make this work you must fix up the first line.


(this is a similar problem to need to know how many files are in the directory)

Scripting folder list

Reply #1
Where exactly do you use this code? Please tell us the name of the component.

Scripting folder list

Reply #2
Where exactly do you use this code? Please tell us the name of the component.


In the album list, it is a custom display. Displays playlist that is in mainDir by organizing them in alphabetical order and displaying them in a hierarchical view.

0
  ...
1
  ...
2
...
...
x
...
y
...
z
...

Makes navigating a large list collection of albums easier.

 

Scripting folder list

Reply #3
I suspected it was Album List, but I am still confused by the word playlist. Album List displays tracks from the media library and playlists are normally not contained in the media library.

Anyway, the Album List processes the formatting code for one track at a time. It is therefore not possible to compute an optimal grouping based on the tracks in your media library. You can however build a static grouping into your formatting code. Use the following code to group all artists/albums/whatever names which start with a number:
Code: [Select]
$ifgreater(1$get(x),1,0-9,...other tests...)

The code below checks whether the first letter of the name is in the range A-C:
Code: [Select]
$puts(x1,$lower($ascii($left($get(x),1))))
$if($strchr(abc,$get(x1)),A-C,...other tests...)