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

MPW Command Reference


Delete

Built-in

SYNTAX

Delete name1 [name2]… [-ac | -an | -ay] [-c | -n | -y] [-i] [-p]

DESCRIPTION

The Delete command deletes one or more files or directories. Normally Delete requests confirmation via a dialog before deleting any directories. You can use the -c, -n, or -y options in scripts to handle the dialog noninteractively.

WARNING
Use this command with caution to avoid unexpected results. See the examples for more information. •

INPUT

None

OUTPUT

None

ALIAS RESOLUTION

This command resolves Finder aliases used as part of any pathname or filename as long as the Finder alias does not occur at the end of the pathname or filename. A Finder alias that occurs at the end of a pathname causes the Finder alias file itself to be deleted. Before it takes this action, Delete puts up a dialog requesting confirmation. There are three options that suppress this confirmation dialog: -ay, -an, and -ac.

STATUS

Delete can return the following status codes:

0

all specified objects deleted (except directories skipped with -n)

1

syntax error

2

error during the delete

4

Cancel selected or implied by -c

PARAMETERS

name1 [name2]…

Specifies the files or directories to be deleted. If a name ends with a colon, the contents (including all subdirectories) of the directory name are deleted. Otherwise, the command deletes the file name.

OPTIONS

-ac

Prevents the display of the "Delete Finder alias file" confirmation dialogs by automatically responding Cancel. This causes Delete to skip the delete for any Finder alias files encountered.

-an

Prevents the display of the "Delete Finder alias file" confirmation dialogs by automatically responding No. This causes Delete to skip the delete for any Finder alias files encountered.

-ay

Prevents the display of the "Delete Finder alias file" confirmation dialogs by automatically responding Yes. This causes Delete to delete all Finder alias files encountered.

-c

Prevents the display of any confirmation dialogs by automatically responding Cancel. This causes Delete to skip the delete for any directories encountered.

-i

Ignores errors--that is, suppresses error messages and returns a status code of 0.

-n

Prevents the display of any confirmation dialogs by automatically responding No. This causes Delete to skip the delete for any directories encountered.

-p

Writes progress information to diagnostic output.

-y

Prevents the display of any confirmation dialogs by automatically responding Yes. This causes Delete to delete all directories encountered.

EXAMPLES

The following command line deletes all items in the MPW folder that end in ".c". The MPW Shell replaces the parameter ≈.c with a list of filenames matching the pattern, and Delete deletes each of these files.

Delete HD:MPW:≈.c

WARNING
Beware of potentially disastrous typographical mistakes such as the following:

Delete ≈ .c

Note the space after the ≈ character. This space causes and .c to be treated as two separate parameters. In this case, Delete deletes all files in the current directory and also attempts to delete a file named .c.

Also note that

Delete ≈:

deletes everything because the filename pattern ≈: expands to the names of all volumes online, including the startup volume. •

When deleting files en masse, it is a good practice to use the Echo command to verify the action of the filename generation operators. For example, the command line

Echo ≈.c

would produce a list of files in the current directory whose filenames end with .c -- as in the following list:

Count.c FStubs.c Memory.c Sample.c TESample.c

 
 


Last Updated July 2000