RemoveDir

Summary

Deletes the contents of one or more directories.

RemoveDir( 'name' ) // Name (required) { // Basic options .RemovePaths // Directories to delete contents of .RemovePathsRecurse // (optional) Recurse into sub-directories? (default: true) .RemoveDirs // (optional) Remove directories as well as files (default: true) .RemoveRootDir // (optional) Remove top-level directory (default: true) // Filtering options .RemovePatterns // (optional) Wildcards of contents to delete (default: *) .RemoveExcludePaths // (optional) Directories to ignore if recursing .RemoveExcludeFiles // (optional) Files to ignore if recursing // Additional options .PreBuildDependencies // (optional) Force targets to be built before this RemoveDir }
Details

RemoveDir() can be used to delete the contents of a directory. By default, the sub-directories are recursed and all files are deleted. Recursion can be disabled (.PathsRecurse), individual sub-directories or files can be ignored (.ExcludePaths and .ExcludeFiles) and files to be deleted can be filtered (.PathsPattern).

Basic Options

.RemovePaths - String/ArrayOfStrings - (Required)

One or more paths can be provided, either as a string or an array of strings. Each path will be traversed and files within it deleted (subject to other settings).

Example:
.RemovePaths = 'folder\'
Or:
.RemovePaths = { 'folderA\', 'folderB\' }


.RemovePathsRecurse - Bool - (Optional)

Directories are scanned recursively by default. Recursion can be disabled.

Example:
.RemovePathsRecurse = false


.RemoveDirs - Bool - (Optional)

In addition to deleting files, directories are also deleted by default. This can be disabled in order to leave empty directories untouched.

Example:
.RemoveDirs = false


.RemoveRootDir - Bool - (Optional)

Directories and sub-directories are deleted by default, including the top-level directory. Deletion of the top level directory can be disabled, while leaving deletion of sub-directories active.

NOTE: .RemoveRootDir is ignored when .RemoveDirs is false.

Example:
.RemoveRootDir = false
Filtering Options
.RemovePatterns - String/ArrayOfStrings - (Optional)

All discovered files will be deleted by default. Deletion can be restricted to certain files or sub-directories by specifying .RemovePatterns wildcards.

Example:
.RemovePatterns = '*.obj' // Delete all *.obj files
Example:
.RemovePatterns = { 'subdir/*.exe', // Delete *.exe files in "subdir" 'subdir/*.pdb' } // Delete *.pdb files in "subdir"


.RemoveExcludePaths - String/ArrayOfStrings - (Optional)

Specific sub-directories can be ignored during recursion.

Example:
.RemoveExcludePaths = 'folderA/' // Ignore contents of folder
Example:
.RemoveExcludePaths = { 'folderA/', // Ignore contents of "folderA" 'FolderB/' } // and "folderB"


.RemoveExcludeFiles - String/ArrayOfStrings - (Optional)

Specific files can be ignored during recursion.

Example:
.RemoveExcludeFiles = 'file.txt' // Ignore file.txt
Example:
.RemoveExcludeFiles = { 'fileA.txt', // Ignore "fileA.txt" 'fileB.txt' } // and "fileB.txt"
Other Options

.PreBuildDependencies - String/ArrayOfStrings - (Optional)

One or more nodes which must be built before this node is built.

The .PreBuildDependencies option ensures the specified targets are up-to-date before the RemoveDir() is executed.

Example:
.PreBuildDependencies = 'DoStuff' // A previously defined target