@tbone: Sorry if these ideas were already discussed above (I've already exceeded my procrastination-time/-budget reading the Opus forum by a solid 3â4 hours today).
I have two suggestions for improvement of SelectEx:
There's no indication that filters activated by SelectEx, are in fact engaged, which can lead to confusion since it's easy to think that there are no items in a folder, when there are. On the other hand, if I use DOpus own filter bar, I have a different background color going on in the file list (see screenshot). Is it possible to achieve such background color or at least some sort of "filters are in play" indication with SelectEx?
Hello!
Would it be possibile to add MAXLENGHTTOTAL, so I can randomly select from a music folder setting the total length of the files? ie:
To select 1 hour of music -> MAXLENGTHTOTAL = 60min
The DO team would need to add support for different background if filter is active.
This specific dialog cannot be changed in size, I would need to rebuild it to support resizing. Alternatively the DO team could allow resizing by supporting the want_resize property on the "dlg.choices" type of dialogs.
@ElimGarak
You could try the SIMILARMETAJS keyword and provide custom js-code to do the mp3 total length calculation I assume.
I'm using this script to randomly , that you kindly made for me more than 4 years ago.
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.
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();
}
How can I adapt it to use the total length of music files instead of total size? I'm sorry, but I'm quite as ignorant as 4 years ago.
You could have learned to write some code in the meantime!? o)
Run this command at some place containing mp3s, it should select random files, not exceeding 1800 seconds playtime in total. Then incorporate this command into what you already have. Don't expect this to work all the time, very basic error handling here, actually it's rather missing completely. o)
You can remove the "DOpus.Output(len + ' ' + item.name); " piece, just for testing. Watch single quote vs. double quote usage and maybe use escaping with "\", when injecting this into the button code you already have.
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;"
Frankly, I don't even know where to start. I've tried running the command and I've got a parsing error.
And I don't have ANY idea how to inject this in the button code.
I'm sorry. If you have a videogame to translate from English into Italian, I'm your man. But this is way beyond me.
If you don't have time, I perfectly understand and don't worry at all. Thanks anyway!
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.
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;"
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');
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:
Open a dialog to let me select a folder.
Search all image files (*.jpg, *.jpeg, .*tif, *.bmp) inside that folder and subfolders.
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.
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.
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.