“打开时"的问题优胜美地的 Applescript 处理程序 [英] Issues with "On Open" Applescript handler in Yosemite

查看:22
本文介绍了“打开时"的问题优胜美地的 Applescript 处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 OSX 10.10 (Yosemite) 中使用 Applescript 时,Apple 似乎改变了一些默认行为.

In using Applescript in OSX 10.10 (Yosemite), it seems Apple has changed some of the default behavior.

on open dropped_files
   display dialog (count of dropped_files)
end open

这个非常基本的 Applescript 突出了问题.如果我从 Finder 中选择一组 6 个文件,然后拖放到该脚本的编译版本上,我会得到响应2",然后是响应4".它应该响应6"......但它几乎就像 Finder 将文件解析成更小的组一样.如果我再次这样做,我会得到不同的数字组合,因此似乎不一致.

This very basic Applescript highlights the problem. If I select a group of 6 files from the Finder, and drop/drop onto a compiled version of this script, I get the response "2" and then the response "4". It should be responding "6"... but it's almost as if Finder is parsing the files into smaller groups. If I do this again, I get a different combination of numbers, so it does not seem to be consistent.

这不是我的应用程序所需的行为,有什么解决方案的想法吗?我从未在旧版本的 Applescript 中看到过这种行为.

This is not the desired behavior for my application, any ideas for a solution? I never saw this behavior with older versions of Applescript.

推荐答案

这种奇怪的效果是由于隔离的文件造成的.可以使用以下命令检查被隔离的文件:

This bizarre effect is due to quarantined files. Quarantined files can be checked with the command:

xattr -p com.apple.quarantine *

根据隔离/非隔离文件的排序顺序,它将分别为每个组(隔离或非隔离)执行打开时"处理程序:例如,1 - 隔离,4 - 非 -隔离,3 - 隔离.您会注意到在此示例中提交了两组隔离文件,这是因为该特定列表是如何排序并提交到打开处理程序的.

Depending on the sort order of the quarantined/non-quarantined files, it will separately execute the "on open" handler for each group (be it quarantined or non-quarantined): e.g., 1 - quarantined, 4 - non-quarantined, 3 - quarantined. You'll notice there are two groups of quarantined files being submitted in this example, and that's because of how that particular list was sorted and submitted to the on open handler.

这种行为相当令人惊讶,我已将其作为错误报告提交给 Apple.可以使用以下命令删除隔离属性:

This behavior is rather surprising, and I've submitted it as a bug report to Apple. The quarantine attribute can be removed with this command:

sudo xattr -dr com.apple.quarantine *

显示正确的文件数.另外,请参阅上面由 regulus6633 提供的 Applescript 技巧,以获取巧妙的解决方法.

to show the correct number of files. Also, see the Applescript trick above by regulus6633 for a clever workaround.

这篇关于“打开时"的问题优胜美地的 Applescript 处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆