Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finder update/refresh applescript not working in 10.8

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.

like image 795
Marcel Vyberal Avatar asked Feb 23 '26 06:02

Marcel Vyberal


2 Answers

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
like image 193
Parag Bafna Avatar answered Feb 25 '26 01:02

Parag Bafna


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

like image 22
Chris L. Avatar answered Feb 24 '26 23:02

Chris L.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!