Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Quickly remove resource forks' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Quickly remove resource forks
Authored by: mj on Jul 21, '03 05:15:57PM

You can empty the resource fork of a file a_file by doing:

echo -n > a_file/rsrc

and this should preserve the other Mac specific info. I don't think there's a difference between removing the resource fork and emptying it. Using this in a shell loop over a globbed file list would let you use it on multiple files and nested directories.

Michael



[ Reply to This | # ]
Should be a hint on it's own!
Authored by: discordantus on Jul 22, '03 01:17:34AM

This one is really a hint in it's own right... I had no idea that you could access the resource fork that way!

OTOH, emptying the resource fork is not the same as deleting it, I think. I'm basing this on the behavior of ResEdit; when you open a file, sometimes it says "This file does not have a resource fork. opening it will create one"... and then it creates an empty resource fork. I would assume based on that that there is some amount of overhead consumed by the resource fork all by itself, or every file would automagickly have one.



[ Reply to This | # ]
Should be a hint on it's own!
Authored by: mj on Jul 22, '03 01:40:53PM
It turns out Rob already has posted a hint about this here, and there's an interested comment at the bottom about using the '..namedfork' route to get at any named fork.

You're right about there being some overhead with a resource fork. When you 'create' a resource fork with ResEdit, it adds a header to the fork. But every file does automatically have a resource fork that you can read from and write to, it just normally has length 0, i.e. no header info.

Michael

[ Reply to This | # ]

yes, this is the preferred way to do it
Authored by: garbanzito on Aug 06, '03 11:25:48PM
... since all it changes is the resource fork.. approaches with cp etc. are more cumbersome, and can lose other info that doesn't take extra space or complicate file transfers.. they will even fail under certain circumstances (such as too little space, permissions problems ...)

if you are writing this into a script, or reading this years later, you'll want to use the non-deprecated form "/..namedfork/rsrc".. another way to express this is:

cat /dev/null >filename/..namedfork/rsrc

and yes, emptying a resource fork is all that's needed (technically, you can never really delete a resource fork on HFS+)

[ Reply to This | # ]