سؤال

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?

هل كانت مفيدة؟

المحلول

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.

نصائح أخرى

tell application "Finder"
    set view to (get current view of front window as string)
    if view is equal to "column view" then
        set t to front window's target
        set p to folder "Myfolder" of folder "parag" of folder "Users" of startup disk as string
        repeat
            if (t as string) begins with p then
                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
            else
                exit repeat
            end if
        end repeat
    end if
end tell
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top