How to install SelectEx

Try again with this please, and always make sure XLOG=dump is on the commandline or the global XLog dumping is active.
Command.Generic_SelectEx.js.txt (133 KB)

  1. looks so yes, but that's easy to add
  2. can be done, the NAME option can take a regex to limit the resultset to specific filetypes/names
    So just add NAME=".(mp3|flac|wav|mp4|whatever)$" to select music files only.

I ran the script with xlog set to dump whilst pointing at the A-Z level, so we're expecting the script to find 10 random letters, but then no music files at the next level down. I can run it at a lower level to find music files if you wish. I've saved the log file and hopefully attached it. I've also attached the m3u file which found 3 non-music files at the next level down.
MyPlayList.txt (572 Bytes)
Script Output.txt (28.1 KB)

Thanks for helping to find the cause of the logging issue.. and it helped! Thx. o))

I checked what version you actually use, it is older than 11.3.1 (a few days only in between to yours).
In 11.13.1 there was a change to the DOpus.Output() method, accepting an error-bool to paint messages red and let the error icon blink. That error-bool is what gets printed if the older Output() method is available only, it does not support the new parameter.

The xlog part takes care for versions now, please try and let me know what shows up. o)
Command.Generic_SelectEx.js.txt (134 KB)

ok will try the new version of SelectEx now.

I checked my version, and 11.13 is the latest production version, whereas 11.13.1 is a beta.

So where those mysterious zeros were printed in the log, was that the error-bool being printed as zero?

I tried the NAME parameter to limit files being output to the m3u (getting dangerous with the jscript now!) and it works a treat!

ok that looks a lot better! This log is for when no music is found at the next level down. Let me know if you want a log for when music is found at the next level down.
Script Output 2.txt (14.2 KB)

[quote]I checked my version, and 11.13 is the latest production version, whereas 11.13.1 is a beta[/quote]Yes, you did allright. Clearly my fault if I expect others to ride the beta-versions.. o)

[quote]So where those mysterious zeros were printed in the log, was that the error-bool being printed as zero?[/quote]Yep!

Ok, now that the output does not fail anymore, I guess we can start looking at how to solve that "find last folder" thing.
No more logs required by now, thanks. o) I'll soon be back.. o)

Hello boogy,

I added some bits to recursivly select folders, that contain a min/max-number of subfolders.
With FOLDERS="subfldmax=0" you'll get only subfolders returned, that are the last in the chain (contain 0 subfolders).

SelectEx LINEAR makevisible itemcount=10 XLOG=all FOLDERS="subfldmax=0" path="<any parent folder>" echo recurse
With FOLDERS="subfldmin=0,subfldmax=3,skipsubfld" you'll get all folders, that have 0-3 subfolders (multi disc album e.g).
The "skipsubfld" will ignore subfolders below folders that already met the min/max criteria.

SelectEx LINEAR makevisible itemcount=10 XLOG=all FOLDERS="subfldmin=0,subfldmax=3,skipsubfld" path="<any parent folder>" echo recurseThere is "depthmin" and "depthmax" as well, to select only folders in a specific distance to the current folder. I think it can somehow be used in conjunction with the min/max count options, but I did not try all variations yet.

Give it a spin o):
Command.Generic_SelectEx.js.txt (137 KB)

Hiya tbone

Have installed, turned on xlog to dump and have had several attempts with CLI and "pointing" at the high level folder, but I can't get beyond 10 random folders at the A-Z level in the folder hierarchy. For example:

SelectEx RANDOM makevisible itemcount=10 XLOG=all FOLDERS="subfldmax=0" echo recurse
SelectEx RANDOM makevisible itemcount=10 XLOG=all FOLDERS="subfldmax=0, depthmin=4" path="<any parent folder>" echo recurse

Most likely it's me!

Perhaps the best way to see if we can get this to work is to come back to the script, which currently reads:

@script jscript
function OnClick(data){
   var cmd = data.func.command, tab = data.func.sourcetab;
   DOpus.Output("Path: " + tab.path);
   cmd.RunCommand('SelectEx PATH="'+tab.path+'" RANDOM FOLDERS ITEMCOUNT=10 SETVAR=SelexResult ECHO XLOG=dump');
   var folders = (""+tab.vars.get("SelexResult")).split("\n");
   for(var f=0;f<folders.length;f++){
      DOpus.Output("Folder:" + folders[f]);
      cmd.RunCommand('SelectEx LINEAR FILES ITEMCOUNTPERC=100 '+
         'PATH="'+folders[f]+'" '+
         'TOFILE="'+DOpus.FSUtil.Resolve("/desktop\\MyPlayList.m3u")+'" APPEND ECHO XLOG=dump'+
		 ' NAME="\.(mp3|flac|m4a)$"');
   }
}

I'd like to amend this to use the subfldmax=0 parameter only if possible because that should keep going until it has found all possible music folders at whatever level, before ten randomly choosing "itemcount" folders.

I'm going to assume that my manual CLI stuff above which I didn't have a lot of luck with is down to me plus some interaction between parameters, so here goes with my attempt at the updated script:

@script jscript
function OnClick(data){
   var cmd = data.func.command, tab = data.func.sourcetab;
   DOpus.Output("Path: " + tab.path);
   cmd.RunCommand('SelectEx PATH="'+tab.path+'" RANDOM FOLDERS="subfldmax=0" ITEMCOUNT=10 SETVAR=SelexResult ECHO RECURSE XLOG=dump');
   var folders = (""+tab.vars.get("SelexResult")).split("\n");
   for(var f=0;f<folders.length;f++){
      DOpus.Output("Folder:" + folders[f]);
      cmd.RunCommand('SelectEx LINEAR FILES ITEMCOUNTPERC=100 '+
         'PATH="'+folders[f]+'" '+
         'TOFILE="'+DOpus.FSUtil.Resolve("/desktop\\MyPlayList.m3u")+'" APPEND ECHO XLOG=dump'+
		 ' NAME="\.(mp3|flac|m4a)$"');
   }
}

Well that worked a treat! Playlist generated fine after Scanning and pre-filtering message then File Function box appeared and recursive scanning was obviously taking place, and no error messages that I could see.

Some things to look at:

  1. output to m3u in filename order if possible (not essential as I can load into mp3tag and sort)
    1a. can't view playlist with notepad as there is are no line breaks - can view with notepad++
  2. possible saving and re-use of candidate folders - takes a fair time to go through the folders so if the candidate list could be saved for re-use that would be useful (again not essential)
  3. the Utility Panel log must have a finite number of entries because the first ones were not available when I scrolled up to the top. Perhaps it's a config parameter...

I'll carry on trying things out, but the short answer is that it works, and wonderfully well.

Thanks tbone.

  1. Sorting the resulting *.m3u requires an additional command once the individual calls to SelectEx finished which add up to the playlist. You can use "sort.exe". It's part of windows since XP:

@script jscript function OnClick(data){ var cmd = data.func.command, tab = data.func.sourcetab; DOpus.Output("Path: " + tab.path); cmd.RunCommand('SelectEx PATH="'+tab.path+'" RANDOM FOLDERS="subfldmax=0" ITEMCOUNT=10 SETVAR=SelexResult ECHO RECURSE XLOG=dump'); var folders = (""+tab.vars.get("SelexResult")).split("\n"); var playlist = DOpus.FSUtil.Resolve("/desktop\\MyPlayList.m3u"); for(var f=0;f<folders.length;f++){ DOpus.Output("Folder:" + folders[f]); cmd.RunCommand('SelectEx LINEAR FILES ITEMCOUNTPERC=100 '+ 'PATH="'+folders[f]+'" '+ 'TOFILE="'+playlist+'" APPEND ECHO XLOG=dump'+ ' NAME="\.(mp3|flac|m4a)$"'); } cmd.RunCommand('sort.exe "'+playlist+'" /o "'+playlist+'"'); }

1a) Expected result, currently "\n" (linefeed) is used to separate entries, should read "\r\n" (carriage return + linefeed) on windows for "dumb" tools to recognize breaks. I should add an option I guess.

  1. You can add TOFILE="folder_list.txt" on the first SelectEx to also save out the result to a file. Reusing that one is currently not possible though.

  2. The number of lines visible can be set indirectly by changing the log buffer size on the ftp preferences.

I actually didn't understand some parts of your response (the upper part mostly), if there is anything I missed or you still think there's something wrong, please try again. o) What I got for sure is your last sentence, telling me it kind of works, so I guess we have a good intermediate result at least! o))

Just tried it some more times with the sort in and it is all working very well. There's two params re logging that I could see - one for FTP buffer size and one for log entries, so I've increased both, and I can see all the entries now.

I was just checking up on the crlf situation. No need to update for me.

That, as we say tbone, is a wrap!

Which means it's excellent.

By the way, I've found and installed your scriptwizard, so hopefully I should be able to keep SelectEx updated...

Superb! Thanks for your kind feedback! o)

The changes made to SelectEx will be available in the original script thread soon.
Updating your custom SelectEx to that official version with the help of SW should be fine.