ApplescriptFinder - 如何检查固定文件夹中是否存在可变文件夹?

问题描述 投票:0回答:1

我试图让脚本检查是否有一个可变的文件夹名称,例如,"文件夹x",存在于一个有文件夹a-z的文件夹中?

脚本的其他部分工作正常,但问题是无论我做了什么,到目前为止,我只得到 "是 "这一行的结果。if exists folder theTitleCV of alias "Comics:" then.

我的脚本到目前为止。

set theTitleCV to "Folder X"
set theTitle to "Folder X-52"

--Creating the folder if it doesn't exists
tell application "Finder"
    if exists folder theTitleCV of alias "Comics:" then
        if theTitleCV is equal to theTitle then
            make new folder of alias "Comics:" with properties {name:theTitleCV}
        else
            set theTitleResult to ((display dialog "Title Options" buttons {theTitleCV, theTitle, "Cancel"} default button 2))
            set theButton to button returned of theTitleResult
            make new folder of alias "Comics:" with properties {name:theButton}
        end if
    else
        return "Yes"
    end if
end tell

先谢谢大家的帮助。

P.S.如果这种类型的问题以前有人问过,也有人回答过,请告诉我该怎么搜索。谢谢:)

applescript finder create-directory
1个回答
0
投票

感谢每个人的帮助,尤其是vadian发现了这个明显的错误。

我现在已经修正了这个脚本,并添加了一个显示对话框。

set theTitleCV to "Folder X"
set theTitle to "Folder X-52"


--Creating the folder if it doesn't exist
tell application "Finder"
    if not (exists folder theTitleCV of disk "Comics") then
        if theTitleCV is equal to theTitle then
            make new folder of disk "Comics" with properties {name:theTitleCV}
        else
            set theTitleResult to ((display dialog "Title Options" buttons {theTitleCV, theTitle} default button 2 with icon ":System:Library:CoreServices:CoreTypes.bundle:Contents:Resources:GenericFolderIcon.icns" as alias))
            set theButton to button returned of theTitleResult
            make new folder of disk "Comics" with properties {name:theButton}
        end if
    else
        tell application "Finder" to activate
        return display dialog "" & return & "Thank you for checking," & return & "but this folder already exists." with title "Folder Already Exists" buttons {"OK"} default button 1 with icon ":System:Library:CoreServices:CoreTypes.bundle:Contents:Resources:AlertNoteIcon.icns" as alias
    end if
end tell
© www.soinside.com 2019 - 2024. All rights reserved.