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

MPW Command Reference


Files

Built-in

SYNTAX

Files [name1] [name2]… [-af] [-c creator] [-d | -s] [-f] [-fr] [-i]
[-l] [-m column] [-n] [-o] [-q] [-r] [-t type] [-x format…] [-y4]

DESCRIPTION

The Files command returns information on one or more directories or files by listing the contents of directories and the requested fields of information for files. If you do not specify any directories or files, Files lists the contents of the current directory.

INPUT

None

OUTPUT

Standard output. For each directory specified, Files generates a list (in alphabetical order) of all subdirectories, followed by all files. For each file specified, the command writes only the name of the specified file unless you specify information fields. (See -l and -x.)

ALIAS RESOLUTION

This command resolves embedded Finder aliases in all input file pathname specifications; leaf aliases are not resolved in input paths. Two options (-fr and -af) allow you to change this default behavior.

STATUS

Files can return the following status codes:

0

all names processed successfully

1

syntax error

2

an error occurred

PARAMETERS

name1 [name2]…

Specifies one or more directories and files. If you omit this parameter, Files lists the contents of the current directory.

OPTIONS

-af

Resolves folder aliases; that is, it causes folder aliases to be treated as folders. If you specify a folder alias on the command line, this option causes Files to list the contents of the directory as if you had specified the actual path of the directory instead of a folder alias. Note that you cannot specify this option with the recursive (-r) option.

-c creator

Lists only those files with the given file creator.

-d

Lists subdirectories only. Normally Files lists both subdirectories and files. Note that you cannot use this option in conjunction with -s.

-f

Writes the full pathname of all files listed.

-fr

Writes the full pathname of all files listed. All aliases are resolved before expanding the path.

-i

Treats all items in the name1 [name2] parameter as files, writing their names and any requested information fields. (Use -l or -x to specify the fields.) Normally Files writes only the contents of directories.

-l

Lists files in a lengthened format, displaying the following information for each file: name, type, creator, size, flags, last modification date, and creation date.

The fifth field of information, flags, displays other file attributes as a string of letters. Each letter is a flag: an uppercase letter indicates that the attribute is set; a lowercase letter indicates that it is not set.

The flags (listed in display order) and their meanings when set follow:

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

File is 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.

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

-m column

Specifies the number of columns of output, where column is any number. Do not use this option in conjunction with -l or -x.

-n

Suppresses the header in the lengthened (-l) or extended (-x) format. The header contains field titles labeling the information displayed in the columns below. Use this option in conjunction with either -l or -x.

-o

Writes only the contents of the directories, not the directory names themselves. Normally each directory name is written above its contents.

-q

Inhibits quoting file or directory names. Normally Files quotes names that contain spaces or special characters.

-r

Lists all subfolders recursively, causing Files to list every file in every directory. Normally Files lists subdirectories and files only one layer deep.

-s

Suppresses the writing of directory names. Use this option, for example, in conjunction with -r to get a listing of all files, excluding directories.

Note that you cannot use this option in conjunction with -d.

-t type

Lists only files of the given type.

-x format

Lists files (-i) or directories in an extended format, displaying the requested fields of information for each. This option generates a listing similar to that produced by -l, except that the fields to be written are determined by format…, where format… is a string composed of one or more of the following letters:

a

Attribute flags. Refer to -l for the meanings of these flags.

b

Logical size in bytes of the data fork.

c

Creator ('Fldr' for folders).

d

Creation date.

f

Finder comments.

g

Group. This applies only to folders on AppleShare.

k

Physical size in kilobytes of both forks.

m

Modification date.

o

Owner. This applies only to folders on AppleShare.

p

Privileges. This applies only to folders on AppleShare.

r

Logical size in bytes of the resource fork.

t

Type.

Note
You can list these letters in any order, keeping in mind that the order determines the position of each field in the output. •

-y4

Displays years using 4 digits.

EXAMPLES

Executing the Files command without any parameters displays the contents of the current directory. For example, if Examples:ProjectorExamples is the current directory, the command line

Files

produces the output

:Commands:
:Sample:
'command pages'

The command line

Files -r -s -f

recursively lists the contents of the current directory, giving full pathnames of all files. Directory names are suppressed.

HD:source:defs.h
HD:source:main.c
HD:source:backup:main.c
HD:source:backup:defs.h
HD:source:junk:tmpfile

The command line

Files -d

lists only the directories in the current directory. Notice that Files -d lists only the first level of directories. You must use -r to list subdirectories and files.

In the following example, Files lists the size and creation date of the {MyIncludes} directory.

Files -i -x kd "{MyIncludes}"

The output appears as follows. Notice how -i is used to avoid writing the contents of the directory.

Name                          Size    Creation-Date
----------------------------  ------  ----------------
HD:Sources:MyIncludes:        365K    8/25/96  9:32 AM

 
 


Last Updated July 2000