牛骨文教育服务平台(让学习变的简单)

Mac OS X: 文件图标变更(Resource Fork)

        在Mac系统里面,文件的一些属性是存储在Resource Fork里面的,这个在其它的系统里面基本上是没有的,是Mac系统的特点。

Resource Fork是存储文件结构化数据的存储方式,是和Data Fork相对比而言的, Data Fork就是我们最普通的一个文件的内容的存储方式了。

        那么Resource Fork里面到底存储什么呢?其实,如果你开发程序,基本上说,可以存储任何东西,但是造成的问题是,在当今的互联环境里不实用。

        而在Mac系统里面,它主要是保存,文件在GUI环境里面显示图标时的图标,窗口形状,程序码等等

 

        这里只说图标-icon. 在GUI环境里面,图标的设定比较容易,比如复制一个图形然后在一个文件的信息窗中粘贴图标旧恶可以了。

 

        下面的方法,也有使用GUI程序的部分,也有使用命令行的部分,命令行适合于管理员的管理和自动化。

 

-----------------------------

For files

1. Create a resource fork file (tempfork)

     . From another file using derez command

     . or use icongrapher to save as resource file

2. update file resource fold with the tempfork file

     . using rez command

     . or use icongrapher to save into a file

3. "setfile -a C" command

-----------------------------

derez -only icns sourcefile > tempicns.rsrc
rez -a tempicns.rsrc -o recipienfile
setfile -a C recipienfile

-----------------------------

For Folders

1. (same as the 1. step in For Files)

2. copy the tempfork file in the folder

     cp tempfork /folder/Icom^M

3. "setfile -a C" command

-----------------------------

derez -only icns sourcefile > tempicns.rsrc

cp tempfork TheFolder/Icon^M

setfile -a C TheFolder

-----------------------------

For Volumes

create a .VolumeIcon.icns file in the root of the Volume

This .icns file is actually a icon file which is save in

Icon Composer or Preview.

3. "setfile -a C" command

-----------------------------

CandyBar can be used for saving other format pictures to Mac icns

Ref:
http://www.macgeekery.com/gspot/2006-09/copying_a_folders_icon_with_terminal_commands