如何在 Automator 中设置背景颜色和文件名文本?

How do you set background color and file name text in Automator?

我最初尝试为我的所有文件夹和默认文件夹设置查看选项,这样我就不必单独更改它们,但现在我只是想恢复我所做的更改。

我遵循了 Lifewire 中的教程,但是 "Set Folder Views" 块中的背景有以下选项:白色、彩色和图片。我认为白色与 finder 的显示视图选项中的默认值相同,但它只是白色。我打开了深色模式,所以这是个问题。

我尝试通过使用颜色选项并在颜色选择器中选择黑色来更正此问题。但是当我运行这个的时候,背景变黄了。

哦,我想都没想就选了"Apply changes to sub-folders"。对于白色选项,我让它 运行 持续了 30 分钟,然后才停止并意识到它在做什么。 然后我想我知道我在做什么,我使用了颜色选项并让 运行 持续 1 小时。

所以现在,我的大量隐藏文件夹都有浅黄色背景。白色选项还将所有文件名文本更改为黑色。

我没有考虑文字,我更正了颜色(我仍然有黑色,但我猜其他东西有所不同)。再一次,我以为我知道自己在做什么,我 运行 没有看就这样做了。这一次,它改变了我实际导航到的文件夹。现在,我有更多的黑色背景和黑色文本的文件夹,所以我无法通过 Finder 查看其中的内容。而且,它甚至不是正确的颜色。本来应该是灰色的。

我放弃了视觉块并尝试使用 Applescript 来解决这个问题,遵循 here and here 中的教程。我写了下面的代码,还是报错

on run {input, parameters}
    set theFolder to "Macintosh HD:Users:user"
    setBackgroundColor(theFolder)
    return input
end run

on setBackgroundColor(aFolder)
    tell application "Finder"
        set subFolders to every folder of aFolder
        repeat with eachFolder in subFolders
            my setBackgroundColor(eachFolder)
        end repeat
        set the background color to {65535, 65535, 65535}
    end tell
end setBackgroundColor

错误:

语法错误

无法获取 "Macintosh HD:Users:user" 的所有文件夹。

我想这是因为文件夹太多了。然后,我尝试使用以下代码设置主目录,但出现错误。

on run {input, parameters}
    set theFolder to "Macintosh HD:Users:user"
    # setBackgroundColor(theFolder)
    tell application "Finder"
        open theFolder
        # tell window 1
        set the background color of window 1 to {65535, 65535, 65535}
        # end tell
        close window 1
    end tell
    return input
end run

错误:

语法错误

Finder 出现错误:无法将 Finder window id 3923 的背景颜色设置为 {65535, 65535, 65535}。

我用它来获得默认颜色(基于黑暗模式的深色或浅色)。我也试过 {65535, 65533, 65534},但也没用

有没有办法让背景颜色和文件名颜色都遵循默认配色方案?

Finder 中的 window 上设置 查看选项 时,某些信息存储在一个名为 .DS_Store 的隐藏 元数据文件 中,在每个 文件夹 中应用了设置。此 文件 默认情况下通常不存在,需要时 created/modified。

重置您所做的更改的一种快速简便的方法是从您的 Home 文件夹,下面的例子复合命令就可以做到这一点。

Terminal 中,它应该默认打开您的 $HOME 目录 ,使用:

find . -type f -name '.DS_Store' -print0 2>/dev/null | xargs -0 -I % rm % ; killall Finder

提示:将鼠标悬停并水平滚动以查看完整代码。

假设 Terminal 中的 PWD$HOME,这会找到所有 .DS_Store filesFinder 中保存这些设置的隐藏元数据文件,在该层次结构中并永久删除它们。 注意:除非您了解它在做什么并且有适当的备份,否则不要使用它!1

1强制警告。删除这些文件是安全的,因为它们不包含正常意义上的用户数据,即文档、图片等,并根据需要重新创建。


set background color to {65535, 65535, 65535} 而言,它需要成为 tell icon view options of window 1 statement/block 的一部分,例如:

tell application "Finder"
    tell icon view options of window 1
        set background color to {65535, 65535, 65535}
    end tell
end tell