1752703 Members
5847 Online
108789 Solutions
New Discussion юеВ

DCL - DELETE

 
SOLVED
Go to solution
Sentosa
Frequent Advisor

DCL - DELETE

Dear ALL,

I need to delete the directory in batch mode but the target directory contains many sub-directories & files.

Do anyone know the effective ways to do in DCL?

Thanks
Sentosa
5 REPLIES 5
Jon Pinkley
Honored Contributor

Re: DCL - DELETE

The Forum Search facity found this:

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1101875

It has several ways.

If you really want to delete everything in the directory, the fastest way is the DFU utility. But you will need to install that.

Jon
it depends
Robert Gezelter
Honored Contributor
Solution

Re: DCL - DELETE

Sentosa,

There are at least two ways of doing this. The first, albeit not the most aesthetically pleasing way is to issue the DELETE [DIRECTORY_NAME...]*.*;* command repeatedly until you get the error (in $STATUS) indicating that there were no files. The highest level directory can then be deleted explicitly.

A somewhat more appealing solution is to use the F$SEARCH lexical to identify all of the data files to walk the subdirectory tree, deleting each subdirectory in turn.

The first method is very easy to do, the second requires more coding.

In both cases, I strongly recommend extensive testing (preferably in a safe environment from a non-privileged, non-system UIC) to avoid the possibility of accidents.

I hope that the above is helpful.

- Bob Gezelter, http://www.rlgsc.com
John Gillings
Honored Contributor

Re: DCL - DELETE

Sentosa,

DELETE has a design flaw when deleting anything more than a few files in a single directory. It does everything backwards. First, directories are deleted top down, which is analogous to attempting to demolish a building from the ground floor upwards. Second, files within directories are deleted in A to Z order, which is the most pessimal case for the way directories are organised, and how deletions are managed. They really should be done Z-A.

If you're on ODS-2 (limited directory depth) and don't mind extraneous error messages, try:

$ set protection=(w:d) [yourdir...]*.dir
$ delete [yourdir...]*.*;*,;*,;*,;*,;*,;*,;*,;*,;*,;*,;*,;*
$ set protection=(w:d) yourdir.dir
$ delete yourdir.dir;

but this may take a very long time if there are many files.

The best solution for deleting entire directories is definitely DFU.

There's some further discussion at:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=625667
A crucible of informative mistakes
Willem Grooters
Honored Contributor

Re: DCL - DELETE

There is a utility DELTREE on the Freeware CD (8.0). It will remove a whole directory tree - including the directory itself) in one command. Use with care - VMS has no 'undelete' so make a good backup first)
Willem Grooters
OpenVMS Developer & System Manager
Sentosa
Frequent Advisor

Re: DCL - DELETE

Thanks