Finder update/refresh applescript not working in 10.8

不羁岁月 提交于 2019-12-17 19:54:20

问题


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

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.

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.


回答1:


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



回答2:


I am having the same exact issue as you. I was about to release my application once I built it with the 10.8 SDK, but Mountain Lion just broke both my "Refresh Finder Windows" and "Show/Hide Hidden Files" menu options. I have tried everything to no avail. The only thing that seems to help is if you wait 60-90 seconds before writing to the Finder Preferences again.

In Terminal:

defaults write com.apple.Finder AppleShowAllFiles TRUE && killall Finder

Wait about a minute to a minute and a half, then reverse the command like so:

defaults write com.apple.Finder AppleShowAllFiles FALSE && killall Finder

(I don't know how to refresh Finder via Terminal, but maybe that delay will help you out in some way.)

That is the only way I currently know of to get the Finder windows to do anything I want them to. Very frustrating; I hope someone can figure this out soon or one of my major selling points just vanished.

-Chris



来源:https://stackoverflow.com/questions/11781373/finder-update-refresh-applescript-not-working-in-10-8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!