Tools: MPW
Advanced Search
Apple Developer Connection
Member Login Log In | Not a Member? Support

MPW Command Reference


SetFile

Built-in

SYNTAX

SetFile fileOrDir1 [fileOrDir2]… [-a attributes] [-c creator]
[-comments comments] [-d date] [-l h,v] [-label label] [-m date]
[-noResolve] [-t type]

DESCRIPTION

The SetFile command sets attributes for one or more files or directories. The options apply to all files/directories listed.

INPUT

None

OUTPUT

None

ALIAS RESOLUTION

This command resolves Finder aliases used as part of any pathname or filename specification. You may use the option -noResolve to override this behavior, which allows you to use SetFile to set the attributes of your Finder alias file.

STATUS

SetFile can return the following status codes:

0

attributes set

1

syntax error

2

any other error

PARAMETERS

fileOrDir1 [fileOrDir2]…

Specifies one or more files or directories.

OPTIONS

-a attributes

Sets the file attribute bits, where attributes is a string of case-sensitive letters. Each letter corresponds to a file attribute: an uppercase letter indicates that the attribute bit is set (1); a lowercase letter indicates that it is not (0). These are the same attributes that are displayed for files in the -l and -x options of the Files command.

The letters and their "attribute set" meanings are given in the table below. Note that attributes that are not specified in the command line remain unchanged.

Attribute

Meaning when set

A | a

Finder alias file.

V | v

Invisible. *

B | b

Has bundle. *

S | s

System file.

T | t

Stationery file.

C | c

File has custom icon.

O | o

File is open.

L | l

Write-locked.

I | i

Initialized (that is, the Finder is aware of this file and has given it a location
in a window). *

N | n

File has no 'INIT' resource.

M | m

Shared file (can be launched multiple times).

W | w

Always switch launch (if possible).

D | d

Located on the desktop. Note that this attribute is not used in System 7. *

* This attribute can also be set for folders.

Note
These attributes are described in the chapter about the File Manager in Inside Macintosh. •

-c creator

Specifies the file's creator, where creator is a string of exactly four characters. For example,

-c 'MPS '

-comments comments

Sets the "Get Info" comments field to comments.

-d date

Sets the creation date, where date is specified using the currently selected format in the Date & Time Control Panel, for example

"mm/dd/[yy]yy [hh:mm[:ss] [AM | PM]]"

The date can also be specified using the MPW uniform format shown below

"yyyymmdd hh:mm:ss"  (Note: ◊ is Option-Shift-v.)

where yyyy, mm, and dd represent the year, month, and day; and hh, mm, and ss represent the hour, minute, and second. Note that when specifying the hour, the values 0 thru 11 indicate A.M. time while the values 12 thru 23 indicate P.M. time.

Note that you must enclose the string in quotation marks if it contains spaces and that, as a convenience, you can use a period (.) to indicate the current date and time.

-l h,v

Sets the icon location, where h and v are positive or negative integer values that represent the horizontal and vertical pixel offsets from the upper-left corner of the enclosing window.

-label label

Sets the value of the Finder label for a file or directory. The label can be specified either by using a number from 0-7, or by supplying a string used to match the current Finder label names. Note that the label values in the Finder's menu are in reverse order. That is, the top label, "Essential", has a value of 7, "Hot" has a value of 6, "In Progress" has a value of 5, and so on down to "Project 2" which has a value of 1.

-m date

Sets the modification date, where date is a string of the same format used for -d. As a convenience you can use a period (.) in place of the usual date string to indicate the current date and time.

-noResolve

Prevents SetFile from resolving the leaf alias in the input file path. This lets you act on the Finder alias file rather than its target file.

-t type

Sets the file type, where type is a string of exactly four characters, for example, -t 'TEXT'.

EXAMPLES

The following command line sets the creator and type for the ResEqual tool:

SetFile ResEqual -c "MPS " -t MPST

This command line sets the modification date of the myFile file:

SetFile myFile -m "5/13/92 12:29"

Using a period (.) as a parameter to -m, the following command line sets the modification date of the myFile and Bar files to the current date and time. Setting the date is useful, for instance, before running the Make tool.

SetFile myFile Bar -m .

SEE ALSO

Files, for the file information displayed by that command's -l and -x options

 
 


Last Updated July 2000