在applescript中,我收到了一个我必须打开的文件路径。Applescript:如何使用默认程序打开文件?
文件路径格式为“/Users/xxx/my/file/to/open.xyz
”。
我想用默认程序打开它。如果它是一个AVI,我需要与视频节目打开它,如果它是一个XLS,与Excel,...
我试过几件事情没有任何成功:
--dstfile contains the previous path
tell application "Finder"
activate
open document dstfile
end tell
- >我” m到处错误1728,告诉我,他是不是能够得到文件
tell application "Finder"
activate
open document file dstfile
end tell
- >同样在这里
tell application "Finder"
activate
open document POSIX file dstfile
end tell
- >同样在这里
我敢肯定,该文件存在,因为我做到这一点的代码执行前:
if not (exists dstfile) then
display dialog "File isn't existing"
end if
我不能使用synthax open.xyz来的......因为我收到此作为一个参数。
请帮我绝望:“(
答:根据答案,我结束了这一点:
set command to "open " & quoted form of dsturl
do shell script command
我强烈建议您避免使用此解决方案。它很脆弱,速度较慢,而且完全没有必要。使用@ kopischke的答案:http://stackoverflow.com/a/10132641/754997 – 2013-06-20 01:18:54