SelectRandom - a script command which allows you to randomly select items by type, count, size, total-size or some other filters. Results can be selected, dumped to console, copied to file collections or returned in env/tab-variables.
"SelectRandom" is obsolete and won't receive any updates.
The functionality of this command has been moved into "SelectEx". Find it here: resource.dopus.com/viewtopic.php?f=35&t=24414
Read this quick-tip on how to update an existing button: resource.dopus.com/viewtopic.php ... 42#p133046
I made this..
- to create a random selection of mp3 albums to listen to
- to select random albums/images to view in a slideshow
- because I have fun doing it.. o)
Params and Features:
FOLDERS - select folders only (default is files or folders)
FILES - select files only (default is files or folders)
NODESELECT - do not deselect items (useful for keeping the selection or adding single items each run)
RANDOM - select a random number of items
SINGLEFOLDER - select a single folder if there are at least SINGLEFOLDERMINCOUNT numbers of folders
SINGLEFOLDERMINCOUNT - number of folders, used in conjunction with SINGLEFOLDER switch
ITEMCOUNT - how many items to select (default is 1)
ITEMCOUNTPERC - how many items to select in percent
ACTION - optional action to perform ("dblclk" eg., lookup FileType ACTION command and options)
COMMANDS - raw commands to run on selection, separate by "\n", make sure param is last
PATH - use external path instead of tab, meant to be used with SETTAB/ENVVAR (items will not be visually selected)
SETTABVAR - the tab scoped variable name, containing chosen items (full paths), separated by ";"
SETENVVAR - the process scoped env-variable name, containing chosen items (full paths), separated by ";"
NAME" - filter items by name/extension (regular expression)
RECURSE - recursive mode, meant to be used with PATH
JSFILTER - for custom scripting filter logic
MINSIZE - to filter files by minimum file size
MAXSIZE - to filter files by maximum file size
MAXSIZETOTAL - to limit total size
COPYTOCOLL - copy results to a file collection
ECHO - output results to the console for easier testing
If you have trouble using it, the script config section offers a trigger to enable some console output, if that does not help, just ask! o)
For selecting a single item out of many, it is recommended to run "ScrollSelectionIntoView" after running "SelectRandom", to scroll the selected item into the visible area. Find it right here: [resource.dopus.com/t/command-scrollselectionintoview/18619/1)
Examples - Usecases:
Select 10 random music albums folders and add these to winamp:
SelectRandom FOLDERS ITEMCOUNT=10 COMMANDS=WinampAddItems
Select a random file, run the doubleclick action and make item visible (chooses a movie and autom. launches player eg.)
SelectRandom FILES ACTION=dblclck COMMANDS=ScrollSelectionIntoView
Select 20 images and start slideshow
SelectRandom FILES ITEMCOUNT=20 COMMANDS=Show SLIDESHOW
Select 1 file out of an "external" folder and provide result in an env- and tab-var called "Result.SelectRandom"
SelectRandom FILES PATH="C:\Items" ITEMCOUNT=1 SETTABVAR="Result.SelectRandom" SETENVVAR="Result.SelectRandom"
Examples - some more:
Select a random item:
Select 10 random items:
Select 10 random folders:
SelectRandom FOLDERS ITEMCOUNT=10
Select 50% of files:
SelectRandom FILES ITEMCOUNTPERC=50
Select a random number of random items:
Select 1-5 random items:
SelectRandom RANDOM ITEMCOUNT=5
Select a single file, or a single folder if there are at least 3 subfolders present.
This creates a button that when repeatedly pressed, opens random folders and eventually "doubleclicks" a file
SelectRandom FILES SINGLEFOLDER ACTION=dblclk
Select 50% of items
To install the command, download the *.js.txt file below and drag it to Preferences / Toolbars / Scripts
After that the command shall be ready to use in buttons, scripts and externally from dopusrt.exe of course.