【问题标题】:Automator Command to Refresh ALL Finder/all Finder WindowsAutomator 命令刷新所有 Finder/所有 Finder 窗口
【发布时间】:2014-03-14 08:34:14
【问题描述】:

我正在使用带有 applescript 的 automator(没有文本,在 finder 中)来打开/关闭隐藏文件夹。我试图在不重新启动查找器的情况下执行此操作,所以我只想刷新每个查找器窗口。 我想将刷新应用到整个查找器/每个窗口,而不仅仅是最顶部的窗口。

使用当前的脚本,我必须手动转到另一个文件夹并返回以显示隐藏文件。我想自动刷新。现在我有它请求权限>如果是,则切换隐藏文件>(这里是我要刷新所有查找器的地方。)

代码:

on run {input, parameters}

    set cur_state to do shell script "defaults read com.apple.finder AppleShowAllFiles"
    if cur_state = "TRUE" then
        do shell script "defaults write com.apple.finder AppleShowAllFiles FALSE"
    else
        do shell script "defaults write com.apple.finder AppleShowAllFiles TRUE"
    end if

    return input
end run 

【问题讨论】:

  • 嗨,你说“刷新”是什么意思?

标签: macos applescript finder automator hidden-files


【解决方案1】:

嗯,

在过去 (Mac OS 9) 早期 (Mac OS 10) 我认为您可以使用更新命令。但现在它的工作方式不同了。

我正在 ML 上执行此操作,我刚刚意识到您无需重新启动 finder 即可进行更改。你只需要让窗口重绘。就像您在列表视图中有一个查找器窗口并进行更改以显示隐藏文件一样。

您可以切换子文件夹显示三角形,您将看到更改。

在不重新启动整个 finder 和所有窗口的情况下,我能想到的唯一方法是将视图翻转到另一个视图并再次返回。

tell application "Finder"
    set theWindows to every window
    repeat with i from 1 to number of items in theWindows
        set this_item to item i of theWindows
        set theView to current view of this_item
        if theView is list view then
            set current view of this_item to icon view
        else
            set current view of this_item to list view

        end if
        set current view of this_item to theView
    end repeat


end tell

在我的测试中,这对我来说效果很好,我将用它来替换我当前使用 killall finder 的切换脚本

【讨论】:

  • 谢谢。我要试试。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-01-10
  • 1970-01-01
  • 1970-01-01
  • 2017-04-10
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多