Finder 更新/刷新 applescript 在 10.8 中不起作用 [英] Finder update/refresh applescript not working in 10.8

查看:28
本文介绍了Finder 更新/刷新 applescript 在 10.8 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用 Apple 脚本来更新 finder 中文件和文件夹的显示.这是该脚本的简化版本:

I have been using apple script for updating display for files and folders in finder. This is simplified version of that script:

tell application "Finder"
    tell window 1 to update items
end tell

我可以看到自 10.8 (Mountain Lion) 更新命令未正确执行或根本未执行.直到 10.8 一切都运行良好 - 在更新命令之后,所有图标都被重新绘制.我用它来显示覆盖图标.

I can see that since 10.8 (Mountain Lion) update command is not properly executed or is not executed at all. Until 10.8 everything was working perfectly - Immediately after update command all icons got redrawn. I use this for showing overlay icons.

你们有遇到过同样的问题吗?我责怪 finder 更改了 Apple 脚本 api,因为如果我触摸 -a -m 文件,它就会更新.所以肯定有一些方法可以更新它.

Have any of you encountered same problem? I blame finder having changed apple script api, because, if I touch -a -m file, it gets updated. So there is for sure some way to update it.

推荐答案

您可以在 finder 中创建 visible 文件以刷新 finder 窗口.

You can create visible file in finder to refresh finder window.

tell application "Finder"
    set currentPath to (POSIX path of (target of front window as alias))
    set filePath to currentPath & "UUID" --create UUID
    do shell script "touch \"" & filePath & "\""
    delay 0.5
    do shell script "rm \"" & filePath & "\""
end tell

这篇关于Finder 更新/刷新 applescript 在 10.8 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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