Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
446 views
in Technique[技术] by (71.8m points)

objective c - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...