检查applescript中文件夹名称的一部分

时间:2013-07-03 20:31:27

标签: applescript

我有一个AppleScript,用于检查我连接到计算机的几个外部HD中的一个,并为其内容编制索引。所有HD遵循命名方案HK_12345,其中前两个字母始终相同,但每个驱动器的数字不同。我希望脚本只检查带有“HK”标识的驱动器,而不管结束编号如何。我有这个,但它不起作用。有什么建议吗?

set folderContains to "HK_"

tell application "Finder"
    set triggerFolder to folder whose name contains folderContains
end tell

tell application "Finder"
    if folder triggerFolder exists then
    -- some other code
    end if
end tell

1 个答案:

答案 0 :(得分:1)

您应该检查disks而不是folders

set diskContains to "HK_"

tell application "Finder"
    set selectedDisks to disks whose name contains diskContains
    -- some other code
end tell