GP SoftwareTwitter
Opus FAQsManualCommandsObjects

Command: SelectEx (extended Select command)

scripting
commands
jscript

#56

The // at the start of one line make that line into a comment that won't be run. Probably some code that isn't needed but might be useful in other situations, or during testing.

The \\ in various paths are there because \ is an escape character in Jscript, and you need to use \\ to get a literal \ in a string.


#57

What exactly do you have trouble with?

  1. Installing the SelectEx addin
    For that, please lookup installation instructions in the thread opening (or other threads in this section, all the same)

  2. Installing and using the code above (it requires the SelectEx addin, so you need both)
    If do no not have a button for this already, enter customize mode (right click any toolbar), then insert a new button. Edit the button (right click) and set the button type to be “Script Function”. Paste the code from above into the button, adjust paths as necessary (use double backslash for every regular slash in a path. Things behind double forward slashes ("//") are commented out from the code, they do not run). Close button editor and leave customize mode by closing all DO windows you did not open before entering customize mode.

Run the button and it hopefully works. o)


#58

Thank you. I have the standard selectex button and I wanted to add a menu item under random (please see image).



#59

These links you posted are not links to images in the first place, their are links to websites showing your uploaded image, so insert them as regular links to make them usable. Anyway, I’d suggest you try to create the button on a(ny) toolbar at first, if that works, enter customize again and drag it into the selectex menu-button. Instructions were given on already and all are still valid. If you encounter problems, consider a quick read in the manual, it’s reachable by pressing and then look out for editing toolbars, customizing buttons. These are DO basics you need to know and… you can make it! o)


#60

Thanks again! I've found how to make it work. However, it asks me for source and target folder but does nothing.
Here's how I've modified it with my paths:

@script jscript
function OnClick(data){
   var PoolFolder = DOpus.Dlg.Folder("Seleziona cartella sorgente", "J:\\00000000 Magicompilation\\Pool");
   var MoveFolder = DOpus.Dlg.Folder("Seleziona cartella destinazione", "J:\\00000000 Magicompilation");
   var CopyFolder = PoolFolder+"\\Copiati";
   
   var cmd = data.func.command; tab.Vars.Set("SexRes") = "";
   cmd.RunCommand('SelectEx XLOG=all RANDOM FILES PATH="'+PoolFolder+'" MAXSIZETOTAL=1000mb ITEMCOUNT=100 SETVAR="SexRes" ECHO');
   var strFiles = tab.Vars.Get("SexRes"); if (strFiles=="") return;
   var arrFiles = strFiles.split("\n"), cmd = DOpus.Create.Command();
   for(var i=0;i<arrFiles.length;i++) cmd.AddFile(arrFiles[i]);
   
   cmd.AddLine('CreateFolder "'+CopyFolder+'" READAUTO=no NOSEL');
   cmd.AddLine('Copy TO "'+CopyFolder+'"');
   cmd.AddLine('CreateFolder "'+MoveFolder+'" READAUTO=no NOSEL');
   cmd.AddLine('Copy MOVE TO "'+MoveFolder+'"');
   cmd.Run();
}

Another question. Do I have to set ITEMCOUNT? May I simply delete it?
Thanks again!


#61

Good, so we're making progress. o)

Make sure to open the "script console" by choosing from the Help menu -> Logs -> Other Logs.
Then run this line by pressing ">" on your keyboard, pasting the following and pressing <enter>. Post the results.

SelectEx XLOG=all RANDOM FILES PATH="J:\00000000 Magicompilation\Pool" MAXSIZETOTAL=1000mb ITEMCOUNT=100 ECHO

I guess there are no files directly below the folder "Pool" or something's wrong with the SelectEx addin preparation/installation. ITEMCOUNT is something we can tackle later, I currently don't know if it's required when used in conjunction with MAXSIZETOTAL, it seems it should work without, not sure though.


#62

Here it is, thanks again!

SelectEx: CmdLine: SelectEx XLOG=all RANDOM FILES PATH="J:\00000000 Magicompilation\Pool" MAXSIZETOTAL=1000mb ITEMCOUNT=100 ECHO
SelectEx: SelectEx_RNDLINEAR():
SelectEx:     FROMCLIP            : undefined
SelectEx:     FROMFILE            : undefined
SelectEx:     FROMVAR             : undefined
SelectEx:     FROMVARDROP         : undefined
SelectEx:     TOCLIP              : undefined
SelectEx:     TOFILE              : undefined
SelectEx:     TOVAR               : undefined
SelectEx:     ITEM                : undefined
SelectEx:     NTH                 : undefined
SelectEx:     RANDOM              : true
SelectEx:     LINEAR              : undefined
SelectEx:     AUTO                : undefined
SelectEx:     SIMILARMETA         : undefined
SelectEx:     SIMILARMETAJS       : undefined
SelectEx:     FILTERDROP          : undefined
SelectEx:     FILTERLIST          : undefined
SelectEx:     MAKEVISIBLE         : undefined
SelectEx:     SKIPITEMSWITHPATH   : undefined
SelectEx:     SKIPITEMSWITHOUTPATH: undefined
SelectEx:     EXACT               : undefined
SelectEx:     GO                  : undefined
SelectEx:     GOPT                : undefined
SelectEx:     USEPATH             : undefined
SelectEx:     APPEND              : undefined
SelectEx:     INDEST              : undefined
SelectEx:     PATH                : J:\00000000 Magicompilation\Pool
SelectEx:     RECURSE             : undefined
SelectEx:     SETVAR              : undefined
SelectEx:     SETENV              : undefined
SelectEx:     FOLDERS             : undefined
SelectEx:     FILES               : true
SelectEx:     SINGLEFOLDER        : undefined
SelectEx:     SINGLEFOLDERMINCOUNT: undefined
SelectEx:     ITEMCOUNTRND        : undefined
SelectEx:     ITEMCOUNT           : 100
SelectEx:     ITEMCOUNTPERC       : undefined
SelectEx:     ACTION              : undefined
SelectEx:     NAME                : null
SelectEx:     MINSIZE             : undefined
SelectEx:     MAXSIZE             : undefined
SelectEx:     MAXSIZETOTAL        : 1048576000
SelectEx:     JSFILTER            : undefined
SelectEx:     JSBREAK             : undefined
SelectEx:     ECHO                : true
SelectEx:     COPYTOCOLL          : undefined
SelectEx:     COMMANDS            : undefined
SelectEx:     DESELECTNOMATCH     : undefined
SelectEx:     NODESELECT          : undefined
SelectEx:     XLOG                : all
SelectEx:     PT                  : undefined
SelectEx:     GET                 : undefined
SelectEx:     Scanning and pre-filtering..
SelectEx:         [J:\00000000 Magicompilation\Pool]..
SelectEx:     Picking items (1653 total)..
SelectEx:     Items (22):
J:\00000000 Magicompilation\Pool\Ghosts (Robbie Williams).wav
J:\00000000 Magicompilation\Pool\Bachelorette (Björk).wav
J:\00000000 Magicompilation\Pool\Dotti, medici e sapienti (Edoardo Bennato).wav
J:\00000000 Magicompilation\Pool\But Not For Me (Chet Baker).wav
J:\00000000 Magicompilation\Pool\Watermelon In East Hay (Frank Zappa).wav
J:\00000000 Magicompilation\Pool\C'Etait Toi [You Were The One] (Billy Joel).wav
J:\00000000 Magicompilation\Pool\Castles Made Of Sand (Jimi Hendrix).wav
J:\00000000 Magicompilation\Pool\Last December (Prince).wav
J:\00000000 Magicompilation\Pool\Inevitabilmente [Lettera dal carcere] (Enrico Ruggeri).wav
J:\00000000 Magicompilation\Pool\Bleecker street (Simon & Garfunkel).wav
J:\00000000 Magicompilation\Pool\To Love Somebody (Nina Simone).wav
J:\00000000 Magicompilation\Pool\Hymn (Ultravox).wav
J:\00000000 Magicompilation\Pool\Poppy (The Beautiful South).wav
J:\00000000 Magicompilation\Pool\Just can't get enough (Depeche Mode).wav
J:\00000000 Magicompilation\Pool\Ask (The Smiths).wav
J:\00000000 Magicompilation\Pool\Stranamore (Roberto Vecchioni).wav
J:\00000000 Magicompilation\Pool\Un Ottico (Fabrizio De André).wav
J:\00000000 Magicompilation\Pool\Street Worm (Spirit).wav
J:\00000000 Magicompilation\Pool\Un Uomo Da Bruciare (Renato Zero).wav
J:\00000000 Magicompilation\Pool\How Do You Sleep (John Lennon).wav
J:\00000000 Magicompilation\Pool\Non È Una Canzone D'amore (Enrico Ruggeri).wav
J:\00000000 Magicompilation\Pool\Underground (Tom Waits).wav
SelectEx:     Done.

#63

Seems like the selection is working, so the problem must be in copy/move process.


#64

It seems I accidentally removed an important piece, sorry. o) So please replace the line..

var cmd = data.func.command; tab.Vars.Set("SexRes") = "";

with..

var cmd = data.func.command, tab = data.func.sourcetab; tab.Vars.Set("SexRes") = "";

and try again.


#65

It works perfectly! Thank you very very VERY much!


#66

Really nice script. Great job tbone! Thanks


#67

Updated to v0.5.3:
v0.5.2 - 1o/2o15

  • fix for inaccessable folders
  • new switch “NOFAIL” to prevent button from aborting in error situations (no items selected when trying to store selection e.g.)
  • new option CLEARVAR to remove stored selections in variables (supports multiple variables, separated by “;”)
  • applying an empty selection container will give info message instead of error, but still fails the execution (override by NOFAIL if undesired)

v0.5.3 - o2/2o16 & o5/2o16

  • fix for FROMFILE creating nonexisting files
  • fix for TOFILE not creating nonexisting files
  • whenever a filter is set, a tab-scoped variable “Script.SelectEx.FilterEnabled” and “Script.SelectEx.FilterEnabled.bfc.drop” is created. The former allows a button to indicate a currently set filter in a folder by icon. The latter var is meant for use with the AutoVars addin (Event: AutoVars (event-handling for variables)), which will clear both vars and reset the indicator button automatically if it’s installed.

#68

Updated to v0.5.4:

  • fix for incorrect output informing about less selected files than expected
  • new option “ENCODING” to specify encoding of created files (unicode,ascii,default)
  • new option “EOL” to specify end of line characters (use “\r” for CR and “\n” for LF or any other text)
  • default eol for file and clipboard content will be “\r\n” from now on, if EOL option is not given
  • TOFILE and FROMFILE now automatically resolve DO aliases, libs and various other non standard paths
  • use of native url script property

#69

A button with these commands does not works for me:

SelectEx NTH=2
Delete

The files are selected only. The delete command seems to do nothing.

Sending these two commands manually does work.

Any ideia why?


#70

Yes, this is because of the unfortunate magic built into some of the native commands and the regular button engine.

If your button does not seem to make use of Select and there are no items currently selected, the Delete command will refuse to do it's job. It's the same for some other native commands iirc. To get around this, you need to add a dummy command at the top. This command will fool DO (or the Delete command) into thinking there are files selected and it will get to work eventually after SelectEx finished its selection. It's weird, I needed to try and was only lucky to remember this oddity, but that's how it is. o)

Select NONE
SelectEx NTH=2
Delete

These kind of irregularities make handling buttons and codes quite unpleasant at times.
This can drive sane people mad, right? o)


#71

I understand now. Thank you for the script and for the help.


#72

Updated to v0.5.5:

  • fix for files not being created if APPEND was used

#73

Bug report, steps to reproduce:

  1. Enable ‘grouped Flat View’. Files with identical names must be visible and there must be enough files to make the scroll bar visible.
  2. Select the last file which has the same name of another file, so that you can scroll up and it be out of sight.
  3. Use “SelectEx MAKEVISIBLE=selected”.

Notice how all files with the same name as the one originally selected are selected, preventing scrolling to the intended file.

I will look into writing a patch to fix that if anyone else reproduce it (to rule out something else being the issue) - if the author does not.


#74

Confirmed! Fix on the way! o)


#75

Feature request for random MP3 selection: select N files from inside selected folders. The way it is now, we can only random select a number of files from within a folder, or from all folders, after applying the flat view.

I'd like to select like 6 albums, getting a number of random MP3 files out of them. Also, it wouldn't be bad to have an additional function to send those files to the default player right away. In this case foobar.

:slight_smile: