本文介绍了与&QUOT问题;在开放和QUOT; AppleScript的句柄约塞米蒂的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在OSX 10.10(优胜美地)使用AppleScript,看来苹果已经改变了一些默认的行为。

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.

此行​​为是相当令人惊讶的,我已经提交了它作为苹果的bug报告。隔离属性可以用这个命令删除:

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 *

显示文件的正确数目。此外,请参阅AppleScript的伎俩通过上面的regulus6633一个聪明的解决办法。

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

这篇关于与&QUOT问题;在开放和QUOT; AppleScript的句柄约塞米蒂的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 18:23