Hitachi

JP1 Version 11 JP1/Script Description and Reference (For Windows Systems)


8.5.12 DeleteFile (delete a file)

Purpose

Deletes a file.

In JP1/Script 07-50 or later, the command supports large files.

Syntax
DeleteFile (PathName [, Option])
Arguments
PathName

Write the full path of the folder or file to be deleted, using a character string or a variable that stores this value. You can use a wildcard in the file name.

Option (from version 05-10)

Specify the following optional value:

Value

Meaning

ExclDir

Delete only the files in the folder specified in PathName, not the folder itself.

Description

The DeleteFile command deletes the specified folder or file. If you omit the option, the command deletes the entire folder, even if it contains files. If you specify ExclDir in Option, only the files in the folder are deleted.

The command returns True on successful execution, or False if an error occurs. True is also returned if no such file can be found (same value as the _ERR_FILE_ reserved variable) or if no such network name or path can be found (same value as the _ERR_PATH_ reserved variable).

Note

Take care when specifying a file in the folder set in the environment variable ProgramFiles (normally the Program Files folder on the system drive) or WinDir (normally the Windows folder on the system drive). For details, see 1.8.2 Command behavior.

Important note

The following types of file names are used in a Windows file system:

  • Long file names with character strings specified by a user

  • Short file names automatically generated by Windows (in 8.3 format)

Therefore, if a wildcard is specified in a file name in JP1/Script, the short file names automatically generated by the OS are also included. In addition, if a wildcard is not specified for a file name, the short file name of another file that exists in the same path as the specified file might be the same, resulting in operations being performed on files you did not intend.

Examples
' Delete the "tempfile.tmp" file in the temporary folder.
DeleteFile (_TEMP_+"tempfile.tmp")
 
' Delete all files with the extension ".tmp" in the
' temporary folder.
DeleteFile (_TEMP_+"*.tmp")
 
' Delete all files in the temporary folder, but keep the
' folder itself.
DeleteFile (_TEMP_, ExclDir)
JP1/Script version

Supported from JP1/Script 01-00.