|Description||Open a Íandom file|
Path, Flag, Extension, Application
|Icon||depends on parameters|
args Path, Par, Ext, App local Subs, Obj, List if(Par < 2) do Obj = R(Path, Par, Ext) else Obj = R(Path, 4, Ext) List = file.listfiles(Obj, 0) Obj = line(List, 1) endif if(not App) do file.doverb(Obj, "open") else do(App, Obj) endif quit Function R(Path, Subs, Ext) local OX, Ran, Obj, Xt, Drap local List = file.listfiles(Path, Subs) local Folders = line(List, 0) if(slice(Ext, 1) == "!") do Xt = remove(Ext, 1) Drap = 0 elseif(slice(Ext, 1) == "*") do Drap = 1 else Xt = Ext Drap = 2 endif @Retry Ran = random(Folders) + 1 Obj = line(List, Ran) OX = file.type(Obj) if(not Drap) do if(Xt == OX) jump Retry elseif(Drap == 1) do quit(Obj) else if(Xt != OX) jump Retry endif quit(Obj)
The script first chooses some random documents in the folder specified, and then opens it in the associated application. Please note: the Windows association (cm_Associate) rather than the internal association (cm_InternalAssociate), is used.
First script parameter can be "%P", "%T", or any implicit real path. Second parameter sets which file will be opened: 0 to open a random file in the first parameter path (root only), 1 - the same, but including subdirectories. If the second parameter is 2, then the first file in a random subdirectory of the directory specified, is opened.
Third parameter specifies an extension of file that must be opened, or must be never opened - in the latter case the exclamation mark ! is specified before the extension. Finally, if the extension starts with *, any file is opened. The %E parameter can also be used.
Fourth parameter, if specified, is a path to the application that opens a file. This setting overrrides the Windows default.
|"%P", 0, "jpg"||Random file with the jpg extension is opened from the current (source) directory|
|"%T", 1, "!ion"||File with any extension differing from ion (especially suitable to exclude the descript.ion file) is randomly chosen from files in the target directory and its subdirectories|
|"c:\one\two", 2, "*whatever or even nothing"||All subdirectories of the c:\one\two directory are analysed, one of them is randomly chosen, and its first file of any type is opened in the associated application|
|"%P", 0, "%E", "c:\SomeApp\Program.exe"||Random file with the same extension than that of the current file, is opened from the current path in the c:\SomeApp\Program.exe application|
|Main Page||Total Commander||PowerPro|