【问题标题】:AppleScript throws an error when creating a folderAppleScript 在创建文件夹时抛出错误
【发布时间】:2015-03-02 13:17:13
【问题描述】:

好吧,也许我很愚蠢,但为什么会这样? 这是我的代码

set openedFile to (choose file with prompt "Select a file to read:" of type {"PNG"})

tell application "Finder"
    set parentFolder to POSIX path of (parent of openedFile as text)
    set icFolder to make new folder at parentFolder with properties {name:"resized imgs"}
end tell

当我尝试运行它并选择一个文件时,我得到了这个:

error "Finder 出错:AppleEvent 处理程序失败。"数量 -10000 怎么了?

【问题讨论】:

    标签: applescript


    【解决方案1】:

    parentFolder 行导致了您的问题。首先,没有“父”这样的命令。 Finder 有命令“容器”来获取父文件夹。此外,您还在使用“POSIX 文件”和“作为文本”将事情搞砸。 opensFile 的格式已经适合 Finder,因此您无需将其强制转换为任何其他格式。

    因此,只需将 parentFolder 行更改为此。祝你好运。

    set parentFolder to container of openedFile
    

    【讨论】:

    • 我以前试过这个,但又得到了这个:错误“不能让 «class chol» \"Development\" of «class chol» \"Documents\" of «class chol» \"应用程序 \"Finder\" 的 «class sdsk» 的 «class cfol» \"Users\" 的 michaelmullins\" 进入类型列表、记录或文本。"编号 -1700 从 «class cfol» 的 «class cfol» “开发” «class cfol» 的“文档” «class sdsk» 的 «class cfol» 的“用户” 到列表、记录或文本
    【解决方案2】:

    我自己想出来的:

    set parentFolder to container of openedFile
    set icnsFolder to (make new folder at parentFolder with properties {name:"resizedicns"}) as alias
    set ic512_2x to duplicate openedFile to icnsFolder
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-04-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-23
      • 2013-01-19
      相关资源
      最近更新 更多