Opening a Folder on the Desktop |
|
on mouseUp
answer folder "Get a folder:"
if it <> "" then
OpenFolder it
end if
end mouseUp
on OpenFolder pPath
switch (the platform)
case "Win32"
set the hideConsoleWindows to true
if char -7 to -1 of the shellCommand is "cmd.exe" then
replace "/" with "\" in pPath
get shell("start explorer.exe /root," & quote & pPath & quote)
else
get shell("start" && quote & pPath & quote)
end if
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 & ConvertPath(pPath) & quote & cr & \
"end tell" into tScript
do tScript as AppleScript
end if
break
end switch
end OpenFolder
function ConvertPath pPath
if char 1 to 9 of pPath = "/Volumes/" then
delete char 1 to 9 of pPath
else
put line 1 of the drives before pPath
end if
replace "/" with ":" in pPath
return pPath
end ConvertPath
Enjoy!
Posted 10/23/2002 by Ken Ray
Revised 10/24/2002 by Ken Ray
Revised 3/26/2007 by Ken Ray (fixed bug where paths with spaces didn't work on OS X; thanks to Scott Rossi for finding this one)
Revised 3/26/2007 by Ken Ray (replaced old "shortcut to folder" approach with "explorer.exe" approach - thanks to Scott Rossi for finding this one as well... :-)
Revised 4/2/2007 by Ken Ray (fixed code for matching 'cmd.exe' - thanks to Scott Rossi again! :-)