Kill Statement

Description

Deletes files from a disk.

Syntax

Kill pathname

The required pathname argument is a string expression that specifies one or more file names to be deleted. The pathname may include the directory or folder, and the drive.

Remarks

Kill supports the use of multiple-character (*) and single-character (?) wildcards to specify multiple files.

An error occurs if you try to use Kill to delete an open file.

Note To delete directories, use the RmDir statement.

See Also

MacID function, RmDir statement.

Specifics (Macintosh)

In Microsoft Windows, Kill supports the use of multiple character (*) and single character (?) wildcards to specify multiple files. However, on the Macintosh, these characters are treated as valid file name characters and can't be used as wildcards to specify multiple files.

Since the Macintosh doesn't support the wildcards, use the file type to identify groups of files to delete. You can use the MacID function to specify file type instead of repeating the command with separate file names. For example, the following statement deletes all TEXT files in the current folder.

Kill MacID("TEXT")
If you use the MacID function with Kill in Microsoft Windows, an error occurs.

Example

This example uses the Kill statement to delete a file from a disk. Since the Macintosh doesn't support wildcards, you can use the MacID function to specify the file type instead of the file name.

' Assume TESTFILE is a file containing some data.
Kill "TestFile"    ' Delete file.

' In Microsoft Windows:
' Delete all *.TXT files in current directory.
Kill "*.TXT"    

' On the Macintosh:
' Use the MacID function to delete all PICT files in current folder
Kill MacID("PICT")