|
|
#1 |
|
Triple-A Player
Join Date: Mar 2004
Location: NYC
Posts: 60
|
Set File Icon on Command Line
Hi,
I know how to set custom folder icons via the command line, but have not been able to figure out how to do this for files. Does anyone know?
__________________
http://spacebit.dyndns.org |
|
|
|
|
|
#2 |
|
Guest
Posts: n/a
|
In both cases the approach is similar:
To set a file custom icon activate the C file attribute: $ SetFile -a C mydoc.txt And the icon must be write into the resource fork. To set a folder custom icon activate the folder custom icon: $ SetFile -a C myfolder and create a Icon? file within the folder with the icon stored in the resource fork: $ cat Icon?/..namedfork/rsrc |
|
|
|
#3 | |||||||||||||||||||||||
|
Triple-A Player
Join Date: Mar 2004
Location: NYC
Posts: 60
|
But with this syntax, where do I specify the image? How do I write it into the resource fork? Just "cp icon.tiff mydoc.txt/rsrc/" ?
__________________
http://spacebit.dyndns.org |
|||||||||||||||||||||||
|
|
|
|
|
#4 |
|
Guest
Posts: n/a
|
Hello. Try using ResKnife utility to edit the resource fork of the Icon? file. Before editing the Icon? file you can copy the icon? file to another file:
$ ditto Icon? myicon $ SetFile -a v myicon |
|
|
|
#5 |
|
Triple-A Player
Join Date: Mar 2004
Location: NYC
Posts: 60
|
The Icon? file is for folders, not documents.
__________________
http://spacebit.dyndns.org |
|
|
|
|
|
#6 |
|
Guest
Posts: n/a
|
Yes, files can have a custom icon in the resource fork with an entry of type icns. If a file has not a custom icon, finder shows the default icon according to its extension, creator code, or type code.
|
|
|
|
#7 |
|
All Star
Join Date: May 2004
Location: london on ca
Posts: 930
|
You can use 'sips' to give an image file a custom icon of itself ('sips' acts on the original file so it might be safer to work on a copy):
Code:
/bin/cp imagefile.jpg donorfile.jpg /usr/bin/sips -i donorfile.jpg Code:
/Developer/Tools/DeRez -only icns donorfile.jpg > tempicns.rsrc Code:
/Developer/Tools/Rez -append tempicns.rsrc -o recipientfile.xyz /Developer/Tools/SetFile -a C recipientfile.xyz Code:
/usr/bin/osascript -e 'tell application "Finder" to quit' -e 'delay 2' -e 'tell application "Finder" to activate' |
|
|
|
|
|
#8 |
|
Guest
Posts: n/a
|
Right answer. BTW, do you know a command line to list the resources of a file.
|
|
|
|
#9 |
|
Triple-A Player
Join Date: Mar 2004
Location: NYC
Posts: 60
|
Perfect! That is exactly what I was looking for, and very clearly explained.
Thank you, -k.
__________________
http://spacebit.dyndns.org |
|
|
|
|
|
#10 |
|
Triple-A Player
Join Date: Mar 2004
Location: NYC
Posts: 60
|
RezDet in the /Developer/Tools folder should do this. Looks like RezWack might too.
__________________
http://spacebit.dyndns.org |
|
|
|
|
|
#11 |
|
Guest
Posts: n/a
|
Hello, thank you, but apparently RezDet is not longer avaiable on OS X:
Code:
$ RezDet . ".": File "."; ### RezDet - Encountered error -43. (GetSysErrText not available in BSD environment. Sorry.) - Fatal I/O error. |
|
|
|
#12 |
|
Triple-A Player
Join Date: Mar 2004
Location: NYC
Posts: 60
|
Works on files for me, not folders.
__________________
http://spacebit.dyndns.org |
|
|
|
|
|
#13 |
|
Prospect
Join Date: Mar 2007
Posts: 31
|
it works both (on files and folders) to me. really good manual for newbies. Thanks
|
|
|
|
|
|
#14 |
|
Major Leaguer
Join Date: May 2006
Location: Paris, France
Posts: 311
|
The instruction on post #7 works for me.
Once I have added an icon to my file, I need to host it on a ftp server. In the transfer, rsrc fork are not preserved, and when it's finally downloaded, the icon is not visible. So, I tried to flatten the file first, with RezWack Code:
/Developer/Tools/RezWack -d myFile -r myFile -o myNewFlatFile Any hint on how to do this? (Give a file a custom icon, and have it preserved when being transferred over ftp. The server is an XServe, if it has any incidence). |
|
|
|
|
|
#15 | |||||||||||||||||||||||
|
Site Admin
Join Date: Jan 2002
Location: Montreal
Posts: 31,938
|
Did you run some command to undo the effect of the RezWack? You need to.
__________________
hayne.net/macosx.html |
|||||||||||||||||||||||
|
|
|
|
|
#16 | |||||||||||||||||||||||
|
Major Leaguer
Join Date: May 2006
Location: Paris, France
Posts: 311
|
Hayne, I am not sure what you mean. Could you elaborate? I was under the impression RezWack would combine a data fork and rsrc fork into one file, allowing to not loose any part when being manipulated by a program that doesn't respect forks. |
|||||||||||||||||||||||
|
|
|
|
|
#17 | |||||||||||||||||||||||
|
Site Admin
Join Date: Jan 2002
Location: Montreal
Posts: 31,938
|
Yes - but when you actually want the file to be used (for an icon), you need the resource fork back the way it was before. I.e. RezWack produces something like an archive format - not something that can be used by software that expects there to be an actual resource fork.
__________________
hayne.net/macosx.html |
|||||||||||||||||||||||
|
|
|
|
|
#18 |
|
Major Leaguer
Join Date: May 2006
Location: Paris, France
Posts: 311
|
Ok, I see. Thank you for the clarification. Now I understand that it's not what I need.
Is there any way to set a custom icon to a file, upload this file to a webserver and still have the custom icon attached to the file and visible by users when they have downloaded the file? In my case, I need to set up a dmg to have a custom icon. If needed, the server can be an XServe. |
|
|
|
|
|
#19 | |||||||||||||||||||||||
|
Site Admin
Join Date: Jan 2002
Location: Montreal
Posts: 31,938
|
There are various 3rd-party utilities aimed at developers that handle DMG attributes like this.
__________________
hayne.net/macosx.html |
|||||||||||||||||||||||
|
|
|
|
|
#20 |
|
Major Leaguer
Join Date: May 2006
Location: Paris, France
Posts: 311
|
Hayne, once again thank you for your reply.
You are of great value to this forum. I do not want to customize the inside of the DMG (like the icon of the Volume mount once open, or the background), but really the icon of the DMG file (what you see in the finder when you have just downloaded it). I want to customize the icon of this file like you would do by showing the Get Info panel for the DMG file, and then drag and drop an image onto the icon. This part is working, but does not "stick" when you transfer the file onto a ftp server. If the tools you are thinking about allow this, could you point me to one? The only ones I could find only do what I described in the first part of this message. |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|