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

大兔子大兔子 提交于 2019-12-13 08:35:36

问题


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.....).

Can anyone please help me out?

回答1:


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.




回答2:


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


来源:https://stackoverflow.com/questions/9096277/how-to-refresh-browser-view-in-finder-windowmac-os-10-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!