我们得到了一些带有项目ID的文件夹,其中包含以下模式:x123_projectname。
我在工作流程中使用Alfred,我需要通过ID查找并打开特定文件夹。 可以从Alfred运行applescript。我是applecript的新手,谷歌帮我创建了这个:
set theString to "/path/to/folder/containing/projects/"
display dialog "What is the ID?" default answer ""
set theID to the text returned of
(display dialog "What is the ID?" default answer "")
tell application "Finder"
activate
set x to theString & "theID" as alias
open x
end tell
但它不起作用 - 你对我有任何暗示吗?
答案 0 :(得分:0)
你的脚本有几个问题,但一般来说你有正确的想法。主要问题是applescript不适用于斜杠分隔路径。 Applescript路径以冒号分隔。您可以使用“posix file”命令将斜杠转换为冒号分隔。试一试。祝你好运。
set theString to "/path/to/folder/containing/projects/"
display dialog "What is the ID?" default answer ""
set theID to the text returned of result
set macString to POSIX file theString
tell application "Finder"
activate
set theResult to every folder of macString whose name contains theID
open theResult
end tell