Command: SelectEx (extended Select command)

Thank you! o)

@H-Ce
There you go. o)

Hi, I'm sorry I didn't make my point.
I know how to edit a button. I don't know how to edit the code in my button to have the script do what I want. Now it randomly selects some music files (based on total size and number) from a folder, copy them into another folder and then cut and paste the original ones to another one. I'd like to change it to select depending on totale length using the command you provided.

Basically, how should I change this:

function OnClick(data){
var PoolFolder = DOpus.Dlg.Folder("Seleziona cartella sorgente", "H:\00000000 Magicompilation\Pool");
var MoveFolder = DOpus.Dlg.Folder("Seleziona cartella destinazione", "J:\AAA SPOTIFY");
var CopyFolder = PoolFolder+"\Copiati";

var cmd = data.func.command, tab = data.func.sourcetab; tab.Vars.Set("SexRes") = "";
cmd.RunCommand('SelectEx XLOG=all RANDOM FILES PATH="'+PoolFolder+'" MAXSIZETOTAL=40Mb ITEMCOUNT=10 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();
}

to implement this:

SelectEx RANDOM ITEMCOUNT=999 FILES JSBREAK="if (typeof len == 'undefined') len=0; DOpus.Output(len + ' ' + item.name); mp3len = item.metadata.audio.mp3songlength; if (isNaN(mp3len)) return false; len+=mp3len; if (len>1800) return true;"

Thanks!

So you know how to edit a button. You also know the button makes use of "SelectEx" command. You probably also know, commands use parameters. Now find SelectEx command in the button code and change/append necessary parameters. This is no rocket science! o)

//change this line
cmd.RunCommand('SelectEx XLOG=all RANDOM FILES PATH="'+PoolFolder+'" MAXSIZETOTAL=40Mb ITEMCOUNT=10 SETVAR="SexRes" ECHO');
//to be this..
cmd.RunCommand('SelectEx PATH="'+PoolFolder+'" RANDOM FILES ITEMCOUNT=999 SETVAR="SexRes" JSBREAK="if (typeof len == \'undefined\') len=0; mp3len = item.metadata.audio.mp3songlength; if (isNaN(mp3len)) return false; len+=mp3len; if (len>1800) return true;" XLOG=all ECHO'); 

Not tested! o)

It worked, thank you so much and... to me it IS rocket science. :smiley:

Glad to hear. o)
In case you did not notice the "1800" in the command line, it represents the total playtime in seconds, adjust as necessary.

Hello! Here I am again with one of my usual annoying requests (if you can help me).

Basically, I'd like a button doing the following:

  1. Open a dialog to let me select a folder.
  2. Search all image files (*.jpg, *.jpeg, .*tif, *.bmp) inside that folder and subfolders.
  3. Check if a image height is over 1080 pixels then:
    a) If the image length is less than 1920 pixels just convert the image into .jpg 100% quality (if already jpg do nothing)
    b) If the image length is more than 1920 pixels, convert the image into 1920x1080 .jpg leaving the quality untouched.
  4. Repeat for all images.

The important thing is that everytime I'd need not to create a second image, but replace the original one. Maybe this can be done in three passages: 1) Save with another name - 2) Delete the original file - 3) Rename the new file as the old one.

Thank you!

(Edit: Per tbone's suggestion below: Need a script/button to batch resize/convert images based on height )

This is way beyond the scope of SelectEx, it may be part of the solution, but I guess you'd be better of trying to get help in the general section and/or learning to write some code yourself in the long run.
I can imagine that using a clever search/filter, combined with some manual actions could get you near as well, that's why I suggest looking for general hints on this.

2 Likes

I wanted to delete half of the files in a folder randomly (large folder > 1 million files). I created this button

SelectEx RANDOM FILES ITEMCOUNTPERC=50

but it didn't seem to work.

Then I realized it took a while to select it all. Great command!

Over 1 million files, ok! I thought I have a lot of files, now I know better. o)
How long did it take to select half a million?

In the first post, the example code that discusses selecting a random file seems to have a typo.

        Examples:
        - Select a random file, run the doubleclick action and make item visible
          (chooses a movie and autom. launches player eg.)
          SelectEx RANDOM FILES ACTION=dblclck MAKEVISIBLE

This code selected a randomized image file and scrolled through the folder so that the image file was shown on screen, but the image file did not double click or open up into a new image viewer window.

I changed the "dblclck" to "dblclk" and got it to open in the image viewer window.

The issue for me is that this opened an image viewer window, and I was unable to scroll to other images. This window seemed to only scroll through the file list of the images that were selected. The button/command did nothing if I opened an image window normally and clicked the button that I'd placed on the image window's toolbar.

What I'm hoping to find/make is a way to go to a folder filled with images (and possibly webms later on) and have a "move to a random image that is inside this directory" button in between the "previous" and "next" buttons.

By the time i started composing the previous post, and switched back to dopus to copy the error message, it was done, so I am guessing 30 seconds to a minute? Originally my post had a different ending suggesting that it didn't work :stuck_out_tongue: but when I switched back to the window, it had, so changed it to works great! :slight_smile:

BTW i was exaggerating it was not a million files, it was less, about 400K i think.
This was just filenames (with no data) for some software testing, indexing files and such.

Is it possible to have this work in an ftp session window? I am trying to use selectex to select files from an ftp site via a text file then manually drag the selection across to download. Works great on local drives but doesn't select anything in a ftp window/session.

v.0.5.8 - 2021.03.07 - fix ftp path handling
Does this version fix the issue for you?

EDIT: Download of v.0.5.8 posted here, moved to thread opening/download section.

1 Like

Works Great! Thanks so much!

You're welcome and thank you for the feedback. o)

Thank you for this great script. I have one slight problem however. All is working fine except this: If I choose the "Filter List (multi)/ Show By Filter" or "Filter List (multi)/ Hide By Filter (unmatched)" options and select more than one filter I get a blank screen as result. When I choose one filter it works like it should be. I think it has something to do with the FILTER FILTERFLAGS="hidenomatch,deselect" option? Can you confirm that this could be a bug in DO in conjunction with combining several filters at the same time or something else?
Thank you for your reply...

Yes, you were are right, it's not necessarily a bug in DO. Selecting by filter only works with a single filter, specific FILTERFLAGS just screw up the result if multiple filters are selected and the command runs repeatedly. I just changed the menu buttons to not use the FILTERFLAGS and do necessary hide/show by separate commands before/after the selection by filter(s) is done.

So I fixed the corresponding buttons, maybe download v0.2 of the menu and try again.

I also removed..
"Filter List (multi) -> Hide By Filter (unmatched)" as it is exactly the same as "Show By Filter".
I also removed..
"Filter List (multi) -> Show By Filter (unmatched)" as it is exactly the same as "Hide By Filter".

Hello tbone,

thanks for the script, I use it mainly for selecting random files by size or quantity using dlg-command. Is there an easy way to use a GUI with radiobuttons instead pulldown-menu?

Hi Sasa, I can't really imagine what you like to accomplish with radio buttons, because I think a regular button or a single (SelectEx) command seems to be a "single choice" kind of input already? You know the capabilities of DOs buttons and menus, if it cannot be done with these regular toolbar elements, there's a chance you could create a custom dialog, but that involves scripting and probably is not the easy way you were thinking of.

What do you mean with "dlg-command" btw.? Maybe that's the key to understand what you're after?

Thanks for reply.

It just would be nice to have one gui where to enter e.g. quantity and then filetypes (all files; audio; video;...) as radiobuttons instead of two pulldown-menus (using dlgchoose).