我创建了一个对我非常有帮助的AppleScript,我希望是否可以自动更改文件夹图标。
该脚本非常简单,它创建一个文件夹,然后在同一文件夹中创建一个空文本文件。
这是脚本:
tell application "Finder"
set newfolder to make new folder with properties {name:My Folder}
make new file at newfolder with properties {name:"read_me.txt"}
end tell
Run Code Online (Sandbox Code Playgroud)
可以自动更改文件夹图标吗?
(当然,我在与脚本相同的文件夹中拥有自定义文件夹图标 (.icns))
下面是一个使用此包中的命令行实用程序“seticon”的解决方案: https: //github.com/vasi/osxutils
它的工作原理是假设您的脚本、icns 文件和新文件夹都位于同一目录中。
tell application "Finder"
set parent_path to ((the container of the (path to me)) as text)
set target_folder_path to quoted form of POSIX path of (parent_path & "my folder")
set icon_path to quoted form of POSIX path of (parent_path & "icon.icns")
do shell script "/usr/local/bin/seticon -d " & icon_path & " " & target_folder_path
end tell
Run Code Online (Sandbox Code Playgroud)