Finder update/refresh applescript not working in 10.8

2.7k views Asked by At

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.

2

There are 2 answers

1
Chris L. On

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

3
Parag Bafna On

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