[Index]

delete


Delete a file or directory, or files and directories.

Unless the force property is set, this job will cause an exception if an attempt is made to delete a non empty directory.


Property Summary

dirCount Count of the directories deleted.
errorCount Count of the errors.
fileCount Count of the files deleted.
files The file, directory, or files and directories to delete.
force Forceably delete non empty directories.
logEvery Logs the number of files and directories deleted every n number of items.
maxErrors The maximum number of errors to allow before failing.
name A name, can be any text.
reallyRoot Flag to indicate that it is the intention to delete files at the root level.

Example Summary

Example 1 Delete all files from a directory.

Property Detail

dirCount

AccessREAD_ONLY

Count of the directories deleted.

errorCount

AccessREAD_ONLY

Count of the errors.

fileCount

AccessREAD_ONLY

Count of the files deleted.

files

Configured ByELEMENT
AccessREAD_WRITE
RequiredYes.

The file, directory, or files and directories to delete. Note the files must be valid file name, they can not contain wildcard characters. This will be the case by default if the files is used to specify the files.

force

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo, defaults to false.

Forceably delete non empty directories.

logEvery

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo, defaults to 0.

Logs the number of files and directories deleted every n number of items. If this property is 1 then the file or directory path is logged every delete. If this property is less than one then the counts are logged only at the end.

maxErrors

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo, defaults to 0.

The maximum number of errors to allow before failing. Sometimes when deleting a large number of files, it is not desirable to have one or two locked files from stopping all the other files from being deleted.

name

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo.

A name, can be any text.

reallyRoot

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo, defaults to false.

Flag to indicate that it is the intention to delete files at the root level. This is to catch the situation where variable substitution is used to specify the file path but the variable doesn't exists - e.g. The file specification is ${some.dir}/* but some.dir has not been defined.


Examples

Example 1

Delete all files from a directory. The directory is the first of Oddjob's arguments.

<oddjob id="this">
    <job>
        <delete id="delete">
            <files>
                <files files="${this.args[0]}/*"/>
            </files>
        </delete>
    </job>
</oddjob>


(c) Rob Gordon 2005 - 2017