FileDelete

Deletes the specified file on the server.

Throws an exception if the file doesn't exist.

Method Signature

FileDelete(file=[string])

Arguments

Argument
Type
Required
Description
Default

file

string

true

The file to delete.

Examples

Script Syntax

Obtaining files within an archive folder and then removing them if they are older than one hour.

var existingFiles = directoryList( expandPath( "/archive/" ), false, "query" );
for( file in existingFiles ) {
	if( dateDiff( "h", file.DATELASTMODIFIED, now() ) > 1 ) {
		fileDelete( file.DIRECTORY & "\" & file.NAME );
	}
}

Result: All files within the archive directory older than one hour will be deleted.

Additional Examples

fileDelete( "my/path/to/file.md" );

Last updated

Was this helpful?