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


Click here to return to the 'remove resource fork in place' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
remove resource fork in place
Authored by: hayne on Jan 03, '03 11:12:30AM

Since the resource fork is stored in a pseudo-file with filename given by appending /..namedfork/rsrc to the original filename, the following alias can be used to remove the resource fork from the original file (without making a new copy as in the hint):

alias rmrsrc 'cp /dev/null \!:1/..namedfork/rsrc'

Sample usage:
foreach file (*.gif)
rmrsrc $file
end



[ Reply to This | # ]
resource fork docs
Authored by: sardu_mac on Jan 03, '03 11:23:34AM
Reference to Apple's (brief) documentation on the "/..namedfork/rsrc" trick: Inside Mac OS X: Performance - Using Pathnames

[ Reply to This | # ]
more explanation
Authored by: hayne on Jan 03, '03 11:38:02AM

I realized I should explain how this works.
The file /dev/null is an empty file which comes standard with all UNIX installations.
(That's simplifying a bit but will do for current purposes.)
Copying this empty file onto the resource fork effectively wipes out the resource fork.
It is necessary to do it this way since the OS prevents removal of the resource fork via 'rm'.

\!:1 is the first argument following the name of the alias when it is invoked - i.e. it is the name of the file. E.g. if I do:
rmrsc foo
then \!:1 is "foo"
The resource fork of a file named "foo" can be referred to as foo/..namedfork/rsrc and this is what I use in the above alias.
The data fork of a file named "foo" can be referred to as: foo/..namedfork/data but that is less useful since standard UNIX utilities act on the data fork anyway (which is the point of the original hint).
Note that this more convoluted naming (foo/..namedfork/rsrc) is now the officially recommended way of referring to the resource fork - the use of the simpler foo/rsrc is still supported for backward compatibility.



[ Reply to This | # ]
remove resource fork in place
Authored by: mickeysattler on Dec 22, '10 04:16:41PM
To strip resource fork data in place with one line in the Terminal, I offer this:

find folder-w-resources -type f -name \*.jpg -exec cp /dev/null {}/..namedfork/rsrc \;
This recursively works in a folder in this directory called "folder-w-resources", finding all things within which are *both* files *and* have names ending in ".jpg", and on those things it copies the null device into the file's resource fork, setting it to a zero-length. Tailor as necessary, make backups beforehand, etc.

[ Reply to This | # ]