GP SoftwareTwitter
Opus FAQsManualCommandsObjects

Opening files with a button (shortcut) using wildcards?


#1

Can wildcards work for opening files with a button using standard functions? I folders with files that change names a lot (filename currentDate.xlsx) and wanted a button that would open the one in the folder, since old ones are moved to a sub-folder.
I.E. open “filename *.xlsx”. Any way to do this with standard functions?

I was thinking of trying to maybe do this with a VBScript function using FSUtil.Wild, but it only returns true or false, and not the string it found? I don’t understand its usefulness if you can’t get the matched string.


#2

Not in standard commands, no.

You can do it fairly easily with scripting, though.

FSUtil.Wild is normally used to see if one string matches one pattern, so true/false is all you need. You know which string matched the pattern because it is the string you just asked it to test.

If you want to find which file(s) matches a wildcard in a script, there are a couple of options:

  • Loop through one of the collections of files Opus gives to you, testing them against the wildcard. (e.g. To find the first file that matches the wildcard in the current folder tab.)

  • Use FSUtil.ReadDir to loop through the files below a particular folder (which need not be the one displayed in any folder tab).

Examples of both types of loops are included in the default example script you’ll see if you create a new script button. You’d just need to add the wildcard check inside one of the loops.


#3

Leo, I found this old thread when I ran into the same problem. ADWCleaner, runs from a portable EXE file, currently adwcleaner_7.1.1.exe. I run it from a simple DOpus button, so in order not to have to change the button with each new version, I routinely delete the version number from the filename when I download it.

But I would like to run it from the button without changing the filename. This is the same problem that falthazar describes.

I tried to select adwcleaner*.exe on the basis of its pattern, and then open the selected files, but it runs into timing issues, and anyway it opens DOpus at a place inconvenient to other work.

The script as you describe is straightforward --- is it still the only effective method? If so, I'll give it a go, and I'll post it if it is successful. In the general case, a dialogue would be useful because there may be more than one match.


#4

You could have a script that shows a dialog with a list of matching exe names, then sets an alias or a variable to point to the chosen one. If what it points to is no longer there, it could ask again the next time it is run.

Using the select command would not be the right way to do it. That is for selecting files in the file display.


#5

I've now written the script, and posted it in the script section.

As always, Leo and Jon, thank for your help.