【问题标题】:Applescript: Select a finder folder using part of a stringApplescript:使用部分字符串选择查找器文件夹
【发布时间】:2015-07-29 17:32:20
【问题描述】:

我正在寻找一种方法/代码来选择特定文件夹中的文件夹,该文件夹包含来自变量的部分字符串

我有文件夹 A,文件夹 A 中有许多文件夹。 folderA 中的所有文件夹都以 5 位数字开头,后跟“_”,然后是简短说明。即,12345_Folder Test 1、54321_Folder Test 2、99999_Folder Test 3,等等……

    tell application "Finder"
        set folderA to folder "FolderA" of folder "Desktop" of folder "MacUser" of folder "Users" of startup disk
        set jobNum to text returned of (display dialog "Enter 5 Digits Only:" default answer "")
        open folderA
        set selected_item to (folder whose name contains jobNum in folderA) -- This is what's failing for me. 
-- from here on I would like to do other things such as run other parts of a script.
end tell

---脚本错误信息

无法获取名称包含文件夹“FolderA”的jobNum的文件夹 启动文件夹“用户”文件夹“prepress_js”文件夹“桌面”文件夹 应用程序“Finder”的磁盘。 ----

非常感谢任何帮助!

【问题讨论】:

    标签: variables applescript directory finder


    【解决方案1】:

    试试这条线:

    set selection to item 1 of (get every folder in folderA whose name contains jobNum) -- This is what's failing for me. 
    

    【讨论】:

    • 感谢克雷格的回复!我稍微调整了一下,现在它按预期工作了。 --设置选择以获取文件夹A中名称包含jobNum的每个文件夹
    • 好消息。请您将答案标记为正确吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-11-14
    • 2017-03-24
    • 1970-01-01
    • 2014-10-29
    • 1970-01-01
    • 2018-11-29
    • 1970-01-01
    相关资源
    最近更新 更多