我想在 mac os 10.5 上刷新所有NSTableView
finder NSBrowserView
。对于刷新图标视图、列表视图和流列表视图,我使用的是苹果脚本。
@"tell application \"Finder\" to update every item in front window"
在浏览器视图中,此脚本仅刷新最后一列。
例如,这个脚本只刷新第三列(icns-copy.m.....)。
谁能帮帮我?
我想在 mac os 10.5 上刷新所有NSTableView
finder NSBrowserView
。对于刷新图标视图、列表视图和流列表视图,我使用的是苹果脚本。
@"tell application \"Finder\" to update every item in front window"
在浏览器视图中,此脚本仅刷新最后一列。
例如,这个脚本只刷新第三列(icns-copy.m.....)。
谁能帮帮我?
它只刷新最后一列,因为每个 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
这是一个快速的'n'dirty 解决方案,因为它一直上升到磁盘的根目录。理想情况下,它会停在最左边一列中显示的文件夹处,但我不知道如何确定它是哪个文件夹。
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