2012-02-01 20 views
-1

我想在Mac OS 10.5上刷新所有NSTableViewNSBrowserView。爲了刷新圖標視圖,列表視圖和流列表視圖,我正在使用蘋果腳本。如何刷新finder窗口中的瀏覽器視圖(mac os 10.5)?

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

在瀏覽器視圖中,此腳本只刷新最後一列。

例如,此腳本僅刷新第三列(icns-copy.m .....)。

enter image description here 任何人都可以幫我嗎?

回答

2

它只刷新最後一列,因爲每個Finder窗口一次只有一個目標文件夾(其內容顯示在最後一列)。解決方法是走上文件夾層次結構並更新父文件夾。

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 

這是一個quick'n'dirty解決方案,因爲它一直到磁盤的根目錄。理想情況下,它會停在顯示在最左列的文件夾中,但我無法弄清楚如何確定它是哪一個。

0
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 
相關問題