0

我有一个 Applescript 应用程序,可以接收拖放到其图标上的文件或文件夹:

on open theDroppedItems
    tell application "Finder"
       set droppedItemSourcePath to (the POSIX path of theDroppedItems)
       ...

在脚本的这一点上,当我的应用程序接收到文件或文件夹时,名为“Droplet”的未知且无用的 Applescript 应用程序会显示一个打开的文件/文件夹对话框。我的脚本是使用 Script Debugger 6 编译为应用程序的。

我不明白为什么这个奇怪的“Droplet”应用会问我一些事情。

4

1 回答 1

1

错误是这theDroppedItems是一个说明符列表alias即使只删除了一个文件并且获取列表的 POSIX 路径也会引发错误

要获取已删除项目的所有 POSIX 路径,请使用

on open theDroppedItems
    set {TID, text item delimiters} to {text item delimiters, return}
    set droppedItemsSourcePaths to POSIX path of (theDroppedItems as text)
    set text item delimiters to TID
    display dialog droppedItemsSourcePaths buttons {"OK"} default button "OK"
...

要一个一个地处理文件,请使用循环

on open theDroppedItems
    repeat with anItem in theDroppedItems
      -- do something with anItem
    end repeat

...

tell仅当您要使用 Finder 术语时才使用 Finder块。

提到Droplet的是你的应用程序。

于 2018-10-16T16:37:44.847 回答