IDL

FILE_DELETE

FILE_DELETE

The FILE_DELETE procedure deletes a file or empty directory, if the process has the necessary permissions to remove the file as defined by the current operating system. FILE_CHMOD can be used to change file protection settings.

Note: On UNIX, if a file to be deleted is a symbolic link, FILE_DELETE deletes the link itself, and not the file that the link points to.

Examples


In this example, we remove an empty directory named moose:

FILE_DELETE, 'moose'

Syntax


FILE_DELETE, File1[,... Filen] [, /ALLOW_NONEXISTENT] [, /NOEXPAND_PATH] [, /QUIET] [, /RECURSIVE] [, /VERBOSE]

Arguments


Filei

A scalar or array of file or directory names to be deleted, one name per string element. Directories must be specified in the native syntax for the current operating system.

Keywords


ALLOW_NONEXISTENT

If set, FILE_DELETE will quietly ignore attempts to delete a non-existent file. Other errors will still be reported. The QUIET keyword can be used instead to suppress all errors.

NOEXPAND_PATH

Set this keyword to cause FILE_DELETE to use the File argument exactly as specified, without applying the usual file path expansion.

QUIET

FILE_DELETE will normally issue an error if it is unable to remove a requested file or directory. If QUIET is set, no error is issued and FILE_DELETE simply moves on to the next requested item.

RECURSIVE

By default, FILE_DELETE will refuse to delete directories that are not empty. If RECURSIVE is set, FILE_DELETE will instead quietly delete all files contained within that directory and any subdirectories below it, and then remove the directory itself.

Note: Recursive delete is a very powerful and useful operation. However, it is a relatively dangerous command with the ability to rapidly destroy a great deal of data. Once deleted, files cannot be recovered unless you have a separate backup, so a mistaken recursive delete can be very damaging. Be very careful to specify correct arguments to FILE_DELETE when using the RECURSIVE keyword.

VERBOSE

The VERBOSE keyword causes FILE_DELETE to issue an informative message for every file it deletes.

Version History


5.4

Introduced

5.6

Added ALLOW_NONEXISTANT and VERBOSE keywords

See Also




Notes


This page has no user notes yet. Be the first one!


This information is not subject to the controls of the International Traffic in Arms Regulations (ITAR) or the Export Administration Regulations (EAR). However, it may be restricted from transfer to various embargoed countries under U.S. laws and regulations.
© 2014 Exelis Visual Information Solutions