Macos 如何打开包含特定字符串的文件夹?(陆委会)
我们得到了一些具有以下模式的项目ID的文件夹:x123_projectname 我在我的工作流程中使用,我需要按ID查找并打开特定文件夹。 可以从Alfred运行applescripts。我是applescript的新手,谷歌帮助我创建了:Macos 如何打开包含特定字符串的文件夹?(陆委会),macos,find,applescript,directory,Macos,Find,Applescript,Directory,我们得到了一些具有以下模式的项目ID的文件夹:x123_projectname 我在我的工作流程中使用,我需要按ID查找并打开特定文件夹。 可以从Alfred运行applescripts。我是applescript的新手,谷歌帮助我创建了: set theString to "/path/to/folder/containing/projects/" display dialog "What is the ID?" default answer "" set theID to the text
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
但是它不起作用-你有什么提示吗?你的脚本有一些问题,但总的来说,你的想法是正确的。主要问题是applescript不适用于斜杠分隔的路径。Applescript路径以冒号分隔。您可以使用“posix文件”命令将斜杠转换为冒号分隔符。试试这个。祝你好运
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
遗憾的是,这还不起作用。我必须这样做:你改变了你问题的参数。我更新了我的代码,让它像你想要的那样工作。同样,您没有正确使用POSIX文件。另外,您的“每个文件夹”代码是一个Finder命令,因此需要在Finder-tell代码块中。注意,我没有测试新代码,但它应该可以工作。