使用AppleScript更改文件夹的图标吗? [英] Change icon of folder with AppleScript?

查看:120
本文介绍了使用AppleScript更改文件夹的图标吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个对我非常有用的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"的解决方案:

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更改文件夹的图标吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆