Command: SelectEx (extended Select command)

Run it as a normal command, not in script mode.


"Not recognized as internal or external command, executable program or batch file".

As an Opus command. It won't be recognised from outside of Opus.

I.e. Put it in an Opus button or hotkey, or into the editor you had in your previous screenshot, but don't turn on script mode in the button/editor.

Thank you! Yes, it works. But now I don't know how I can modify my button script to incorporate this. :slight_smile:

Please do some research on the forum or the documentation. Editing a button is such a basic task in DO, we should not cover that here. Consider to open a new thread in the general section if you cannot figure this out.

The latest beta automatically makes these dialogs resizable.

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!