Set filetypes from the command line

There are two ways to establish a file’s type from the command line. The first is to use the addattr command, like this:
addattr BEOS:TYPE text/html filename(s)
This works just fine when the file or files in question don’t yet have a filetype. If they do, the existing type will be overwritten with the new type.
To achieve the same effect but with somewhat simpler syntax, try the settype command, which can be used with a -t flag to establish a MIME type, or with an -s flag to establish a signature. For example:
settype -t text/html filename(s)
Finally, you can use -preferredAppSig preferred_app_signature to change the preferred application with which the file is associated.
Settype is great for batch-changing type or preferred application on some criteria, as in this little script, which gives a new type to each of the resulting files turned up by a command-line query:

for f in $(query "query string here" ) ;  do
	settype -t "new_type_here"


No comments so far.

(comments are closed)