问题描述
我创建了一个对我非常有帮助的 AppleScript,我希望是否可以自动更改文件夹图标.
i've create an AppleScript very helpful to me and i wish if it is possible to automatically change the folder icon.
这个脚本很简单,它创建一个文件夹,然后在同一个文件夹中创建一个空文本文件.
This script is very simple, it create one folder, then create one empty text file in the same folder.
这是脚本:
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
是否可以自动更改文件夹图标?
Is it possible to automatically change the folder icon?
(当然,我在脚本所在的文件夹中拥有我的自定义文件夹图标 (.icns))
(I own my custom folder icon (.icns) in the same folder as the script, of course)
推荐答案
这里有一个使用命令行实用程序seticon"的解决方案:https://github.com/vasi/osxutils
Heres a solution that uses a command line utility "seticon" found in this package: https://github.com/vasi/osxutils
假设您的脚本、icns 文件和新文件夹都在同一目录中.
It works on the assumption your script, icns file and new folder are all in the same directory.
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
这篇关于使用 AppleScript 更改文件夹的图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!