Delete previous versions of a file




VSupported on OpenVMS
xcall PURGE(file_spec)



A field, literal, or record that contains the specification of the file or files to be deleted. (a)


The PURGE subroutine deletes all but the most recent version(s) of the specified file(s) from the specified directory.

The version with the highest version number is not deleted.

File_spec can contain wildcards, but it cannot contain a version number. The default directory is established at log‑in or by the SET DEFAULT command. If the PURGE subroutine cannot find the specified file(s), a “File not found” error ($ERR_FNF) or “Bad filename” error ($ERR_FILSPC) is generated.

The rules associated with the DELET subroutine also apply to the PURGE subroutine.

If the PURGE system service fails, a “DCL purge error” ($ERR_PURGE) is generated, and the OpenVMS error that caused the failure is available through the %SYSERR function.


Because PURGE requires the command line interpreter, if you are using xfServerPlus, you cannot XCALL this routine from within a shared image.

See also