[fa.info-vax] Deleting dir trees

stokes%cmc.cdn%ubc.CSNET@CSNET-RELAY.ARPA (Peter Stokes) (10/08/85)

This is a copy of a message I sent to Mike Iglesias regarding deleting 
directory trees.  All this command file does is recursively delete the 
directory structure eight times over  (max sub-dir depth).  Efficient 
and destructive!

Peter Stokes 
Canadian Microelectronics Corporation
Queens University Kingston Ontario

==================

$	On Control_Y Then Exit
$	Set NoVerify
$
$!	ZAP ... Delete Entire Directory Structure .. v1.01  C. Jeffrey
$
$	Inquire P1 " Enter Directory To Destory "
$	Inquire CONT " Confirm Destruction "
$
$	If .NOT. CONT Then Exit
$
$	Set Default 'P1'
$	Set Protection = (O:RWED) [...]*.*;*
$
$	Set Noon				! Supress Errors
$
$	Count=0
$
$Loop:
$		Count = ( Count + 1 )
$		Delete [...]*.*;*
$		If (Count .LE. 8)Then Goto Loop
$
$	Set On
$	Exit

KVC@engvax.UUCP (10/09/85)

> I used to have a huge recursive command procedure, but then I found:
>
> $ set file/nodirectory <target>
> $ delete <target>
>
> This seems to work.  I am not sure what happens to all the levels
> underneath <target>, but they seem to go away.  Maybe someone else
> out there knows.

oops!!!  This is bad news!!!  What happens is the files still exist but
no longer have directory entries.  They are lost files and still use up
disk space and disk quota of whoever owns them.  You cannot reclaim the
disk space without finding the files so they can be deleted.  You shoul
use ANALYZE/DISK/REPAIR on your disks to find the files.  They will show
up in [SYSLOST] of the disk in question.  You can then delete them.
They will no longer be in the form of directory trees.  [SYSLOST] is
flat, though a bunch of bad .DIR files will be there as well.

> As a side note, I am not sure why:
>
>	DELETE [...]*.*;*
>
> doesn't work.  It seems to handle the first instance of a subdirectory,
> but bombs on all subsequent.  For example:

This will properly delete all files in the directory tree that are NOT
non-empty directories.  You will get errors when it tries to delete directories
that are not empty because they have directories under them.  Once the
command completes, you will be left with a tree consisting of only
.DIR files, with the lowest level gone.

Repeating this very command several times (up to eight, since that's as
far as VMS allows directory nesting (unless you cheat) will then prune
the tree from the bottom up.

	/Kevin Carosso       engvax!kvc @ CIT-VAX.ARPA
	 Hughes Aircraft Co.