0

我有一个脚本,它只允许我通过右键单击文件来将标签添加到文件中。我选择标签,脚本会自动添加它们。它们有一个特定的形式:“&tag”,它们用空格分隔。

我想做的是拥有一个自动化应用程序,其中一个 shell 脚本按特定条件搜索文件,并且该脚本将结果传递给一个 applescript。

所以我的自动化应用程序以“运行 Shell 脚本”块开头,这是其中唯一的内容。

mdfind '(kMDItemContentTypeTree == "public.image" || kMDItemContentTypeTree == "public.video") && kMDItemFinderComment == "*&tag*"cd'

这将返回一个文件列表及其 POSIX 路径。像这样:{"/User/path1/file1","/User/path2/file2",etc.}

然后我有一个“运行 Applescript”框,我想在其中访问文件及其评论,但无论我尝试多少,它都不起作用。我试过使用 POSIX 文件,或者从“tell finder”块访问评论。没有任何效果。

这是最简单的代码,我认为应该可以正常工作,但事实并非如此!

on run {input, parameters}
  repeat with f in input
    display dialog (comment of f) as text
  end repeat
  return input
end run

有谁知道问题可能是什么?我错过了什么?请帮帮我!

谢谢!

4

1 回答 1

0

Try something like this:

on run {input, parameters}
    tell application "Finder"
        repeat with i from 1 to number of items in input
            display dialog comment of (POSIX file (item i of input) as alias) as text
        end repeat
    end tell
    return input
end run
于 2012-11-06T17:29:37.963 回答