file delete multiple/recursive ...

Prev Next

Function Names

file delete multiple, file delete multiple all, file delete recursive, file delete recursive all

Description

These functions delete multiple files in specified directories. Wildcards are supported to select files to delete.
file delete multiple ... Only the directory / directories specified in 1st parameter will be considered to search and delete files
file delete recursive ... All subdirectories are also included for searching and deleting these files
file delete ... all will try to delete all files, skipping those which cannot be deleted. No exceptions asserted in this case.

Attention: System files are not touched, but hidden files are. No directories will be deleted.

Call as: procedure or function

Restrictions

Indirect parameter passing is disabled.
Wildcards are allowed on file names only

Parameter count

1-2

Parameters

No.TypeDescription
1
input
set or string path name(s)

Names of existing directory paths to delete. Nothing is deleted if the parameter is empty. If the parameter contains a blank string, then current directory is assumed. If the 2nd parameter is not specified, then all files in the specified path are affected.

Opt. 2
input
set or string file name(s) or patterns

If number of names or patterns in this function parameter equals to number of path names, then a 1:1 relationship is assumed, i.e. 1st path relates to 1st name, 2nd path to 2nd name, etc. If this parameter contains fewer elemeents, then the last element will apply for the remaining path names. If this parameter contains more elements, then the excess names or patterns will be ignored.
Attention: Nothing will be deleted if this parameter contains a blank string or empty set.

Default value: * (all files)

Return value

TypeDescription
numeral Number of files deleted successfully

Exceptions

File not found
File locked by another application
File not accessible
File is a directory

Examples

               directory create( My Folder );

               file copy ( {3 : Example_Program.b4p}, { Test123.txt, Test456.txt, "My Folder\Test789.txt" } );
               echo(file delete multiple all ( ".", "Test???.txt" ) ); // Returns 2

               file copy overwrite ( {3 : Example_Program.b4p}, { Test123.txt, Test456.txt, "My Folder\Test789.txt" } );
               echo(file delete recursive all ( ".", "Test???.txt" ) ); // Returns 3

               directory delete( My Folder );

Output

2
3
Try it yourself: Open LIB_Function_file_delete_multiple.b4p in B4P_Examples.zip. Decompress before use.

See also

file delete ... Functions
directory delete multiple/recursive ... Functions