Useful utilities - GetFileInfo and SetFile

Oct 18, '01 05:23:52PM

Contributed by: rgoer

Stuck (almost uselessly) in /Developer/Tools/ are two rather incredible little guys you should immediately link (ln -s) right into /usr/bin/. They are GetFileInfo and SetFile.

For more on how to use these tools, including exactly how to create the links and how to hide a given volume on the desktop (for example), read the rest of this article.

The first thing to do is to link the tools into the standard bin directory. Type this in your Terminal window:

 sudo ln -s /Developer/Tools/GetFileInfo /usr/bin/getinfo
sudo ln -s /Developer/Tools/SetFile /usr/bin/setfile
Note that we're assuming you have the Developer Tools installed! Now type rehash to make sure the system is aware of the new applications.

Let's say you created a separate partition to hold your swap directory. For clarity's sake, you called it swap. The dedicated swap partition thing is going great, but you are annoyed by the appearance of swap on your desktop and you don't want to hide all your drives. Just swap. Well, here we go:
getinfo /Volumes/swap
You should see something like this:
directory: "/Volumes/swap"
type: ""
creator: ""
attributes: avbstclinmed
created: 10/05/2001 22:31:07
modified: 10/18/2001 20:10:53
That lower-case "v" on the attributes line denotes a "0" (as opposed to "1") for the attribute "is invisible." That is quite easy to fix, with SetFile, which we cleverly ln'ed into a useful location:
sudo setfile -a V /Volumes/swap
A getinfo of /Volumes/swap should now reveal a V in the attributes line. A quick relaunch of the Finder is now all that stands between you and an invisible swap partition.

Attributes aren't the only handy part of SetFile, though. Executing SetFile with no options, arguments, or target files will return the proper usage guidelines, along with some rather extensive notes (I suppose that makes up for the lack of manual pages). Attributes, file creator, creation date, modification date, and file type are all at your fingertips.

Comments (5)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20011018172352562