Command: SelectEx (extended Select command)

tbone, i just had another idea for the "auto select" part. I would suggest an additional option to prevent the auto select action, in case we move out of a folder, instead of moving into it, which i see as the standard case. Does that make sense to anybody else?

This suggestion also applies to Leo's original "standalone" version, of course. :bulb:

Kind of makes sense, yes.. I'll have a look. o)

Updated to v0.5:

  • new switch "INDEST", select items in destination instead of source (for SIMILARMETA/JS only)
  • missing output fixed for DO versions older than v11.13.1
  • new script config "AutoSelect.Actions" to customize on what type of folderchange the autoselection is done
  • new features for the FOLDERS switch in combination with RECURSE and PATH
    -> depthmin/depthmax to limit results to folders with a specific distance to the source folder
    -> subfldmin/subfldmax to limit results to folders with a specific number of subfolders
    -> skipsubfld to pre-filter/exclude all (sub)folders for which the subfldmin/max criteria already matched

The new INDEST switch is similar to the native "Select SOURCETODEST=noext", but allows custom rules for determining the items to be selected. This command selects all items in dest, which names are equal up to the 8th digit from the selected items in source.

SelectEx SIMILARMETAJS="return selItem.name.left(8)==item.name.left(8);" INDEST

The new features for the FOLDER switch allow to limit randomly or linearly picked folders by their number of subfolders or distance to the source. This command picks 10 random folders, that do not contain any more subfolders. As the source folder is a music collection, you should get 10 random albums (progress and result verbosly printed to the console in this case).

SelectEx PATH="C:\MyMusic'" RANDOM FOLDERS="subfldmax=0" ITEMCOUNT=10 ECHO RECURSE XLOG=all

Nice work again, tbone! Thanks for the new AutoSelect.Actions function. Works like a charm.

Following looks quite promising: SelectEx PATH="C:\MyMusic'" RANDOM FOLDERS="subfldmax=0" ITEMCOUNT=10 ECHO RECURSE XLOG=all, to play around with. Possibly you need to fine tune this part of the script. Because when it is applied to a root level, as M:, containing all the music categories in subfolders to choose from, the script seems to try to include stuff from the trash bin, which results in a script error message. As in this example:

Scanning and Prefiltering
[M:]..
[M:$RECYCLE.BIN]..
Error in line 403, Position 6
permission denied. (0x800a0046)

Thank you. It good to see there still some life here. There is so many option that it offer that I find too overwhelming, so I will stick with the default Button/Menu provided.

I do want to know something, what does the "Filter-dropdown" "Filterlist" do? It doesn't seem to do anything for me, do I have to modify it?

Hi dopo, seems I missed your post, sorry for that. Regarding your question, maybe you like to look in the link below.
The menu/dropdown described there is basically the same in SelectEx, maybe you just have no filters created yet?
"Select by Filter buttons" (["Select By Filter" menu button))

Hello! I'd like to have a new random option, but I'm quite unable to do it myself, so I'm here asking for an help.
Basically, what I need is a command that:

  1. Selects n random files in a folder, depending on the MB value I set.
  2. Copies this files in another folder I specify.
  3. Optionally, moves the original files in a subfolder of the first one (ie. called "Copied")

We could call it "Copy x MB of files to folder".

Is it possible? Thank you very much!

Try this after adjusting the folders at the top and the line starting with SelectEx in regard to MAXSIZETOTAL and ITEMCOUNT.

@set MoveFolder=D:\RNDTest
@set CopyFolder={sourcepath$}\Copied

Select ALLFILES 
SelectEx RANDOM FILES MAXSIZETOTAL=1mb ITEMCOUNT=100 DESELECTNOMATCH

CreateFolder {$CopyFolder} READAUTO=no NOSEL 
Copy TO {$CopyFolder}

CreateFolder {$MoveFolder} READAUTO=no NOSEL
Copy MOVE TO {$MoveFolder}

I think you also need to switch paths for the Move/CopyFolder and make sure to use DO v11 (your info says you are on v10?).

I need to update my profile. I have DO 11.17 x64.
:wink:

Thanks for the answer. I forgot to say I need to input the destination folder.
Basically, I have a big "pool" folder from which I need to extract about 1GB each time in different targets.

I saw some commands in SelectEx open a dialog and I wished it could be the same.

Eat this! o) Adjust paths and SelectEx options as needed, switch button to type "script function" as well.

@script jscript
function OnClick(data){
	var PoolFolder = "D:\\tmp\\2015_11_12_delme"; //DOpus.Dlg.Folder("Select Pool", "D:\\pool");
	var MoveFolder = DOpus.Dlg.Folder("Select Move-Target", "D:\\RNDTest");
	var CopyFolder = PoolFolder+"\\Copied";
	
	var cmd = data.func.command; tab.Vars.Set("SexRes") = "";
	cmd.RunCommand('SelectEx XLOG=all RANDOM FILES PATH="'+PoolFolder+'" MAXSIZETOTAL=1mb 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();
}

First of all, REALLY thank you and happy new year.
As I told you, this is all new to me, so I have a couple of questions.

  1. I understand I have to copy this into the .js script (I edited the paths, at least THAT I know how to do :slight_smile: ), but how can I add the command in the toolbar button?
  2. Is it right that the temp path has // instead of \ ?
    Thanks again!

In the command editor, there is a dropdown menu, where you can choose "script" from the "function" menu. That should do it.

This is some internal command, i suppose, which is not using Windowses backslash syntax.

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.

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)

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


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)

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!