Search code examples
objective-capplescriptmacos-carbonfinderappleevents

How to refresh browser view in finder window(mac os 10.5)?


I want to refresh all NSTableView in NSBrowserView of finder on mac os 10.5. For refreshing icon view , list view and flow list view, i am using apple script.

@"tell application \"Finder\" to update every item in front window"

In browser view this script is only refreshing last column.

For example , this script is refreshing only third column(icns-copy.m.....).

enter image description here Can anyone please help me out?


Solution

  • It's only refreshing the last column because every Finder window has exactly one target folder at a time (whose content is displayed in the last column). The solution is to walk up the folder hierarchy and update the parent folders as well.

    tell application "Finder"
        set t to front window's target
        repeat
            try
                update every item in t
                set t to t's parent -- go one level up
            on error                -- e.g. when you reach root
                exit repeat
            end try
        end repeat
    end tell
    

    This is a quick'n'dirty solution since it goes up all the way to the disk's root. Ideally, it would stop at the folder which is displayed in the leftmost column, but I couldn't figure out how to determine which ohe it is.