Reveal file on Windows
Trevor DeVore
lists at mangomultimedia.com
Wed Sep 22 16:05:27 EDT 2004
I was looking through the archives to find out how to reveal a file on
Windows and have it selected in Win Explorere but didn't find anything
on it. After querying my good friend Google about it I came across
this. To reveal a file on Windows you can use pass commands to
explorer.exe.
explorer.exe /select, "c:\Path to my file\myFile.txt"
This would open windows explorer with the file myFile.txt selected.
I've tested this on Win XP so far and it works great. I can test on
some other platforms later on to see if this breaks and my joy was for
naught but if anyone wants to play around with it here are two
functions for cross-platform opening a folder and revealing a file.
/**
* Opens a folder on the desktop. (Modified from Ken Ray's example)
*
* @param pPath Path to folder to open.
*/
on libSys_OpenFolder pPath
switch (the platform)
case "Win32"
replace "/" with "\" in pPath
set the hideConsoleWindows to true
get shell("explorer.exe /root,"& quote & pPath & quote)
break
case "MacOS"
if the systemVersion >= 10 then
get shell("open " & quote & pPath & quote)
else
put "tell application " & quote & "Finder" & quote & cr & \
"activate" & cr & \
"open folder " & quote & revMacFromUnixPath(pPath) & quote & cr & \
"end tell" into tScript
do tScript as AppleScript
end if
break
end switch
end libSys_OpenFolder
/**
* Opens a window with the file selected.
*
*/
on libSys_RevealFile pPath
switch (the platform)
case "Win32"
replace "/" with "\" in pPath
set the hideConsoleWindows to true
get shell("explorer.exe /select,"& quote & pPath & quote)
break
case "MacOS"
put "tell application " & quote & "Finder" & quote & cr & \
"activate" & cr & \
"reveal file " & quote & revMacFromUnixPath(pPath) & quote & cr & \
"end tell" into tScript
do tScript as AppleScript
break
end switch
end libSys_RevealFile
More information about the use-livecode
mailing list