Launching files with unknown file extensions

If there a better way of achieving the below. Basically I always know the name of the ‘file’ minus it’s extension, but the extension will always be one of the three choices. The file is always stored in the same location, but under a year/month directory structure depending on when it was created. I always know where to find it to ‘launch’ it. The below works fine, it just seems long winded.

The files live on a server, so basically under windows command line dir server\location\year\month\filename.* would retrieve the whole filename but I don’t want to shell out twice if I can avoid - running batch file may be the answer. Open to views and suggestions.

settings(5) is the server UNC

[code]dim yr, mnth, dte, doc, fname as string
if right(settings(5),1)="" then
end if


Dim f as FolderItem
dim i as Integer
dim ext(3) as String

for i=1 to 3
If f.exists then
Dim s As Shell
s=New Shell
#if TargetWin32
s.execute fname
exit For
end if[/code]

I’d say you can skip the shell to launch the file.
Just do


and it will open with the right program

Thank you.

Is there a way to choose the proper program for launch, other than the standard program in the OS?

I want to be able to choose one of several programs to open a file with during runtime.

Victor, that depends on the OS. On OSX, for instance, you’d launch the desired app with FolderItem.Launch, then use an AppleEvent to send it the file(s) to open. Or use one of the OS functions that you can find in macoslib.

On Windows and Linux, you’d rather start the app with the shell and pass the path(s) to the file(s) as arguments.

Using OSX.

With Launch the file opens with the standard program set in OSX. I want to open it in other suiting programs.

Problem not yet solved but I avoided it by opening the program via the shell, with the filename as parameter. But not the solution I hoped for.

Victor, if you do that, then use then “open” command. If you don’t yet, enter “open -h” to learn how to use it. Do not launch the executable inside /Contents/MacOS/ directly, or you’ll get odd side effects such as starting multiple copies of the same app, and other things.

Thanks for the tip. It’s working fine now with any program i prefer.