[fa.info-vax] Deleting a directory tree

sasaki@HARVARD.HARVARD.EDU (Marty Sasaki) (10/09/85)

Here is a DCL program to delete a directory tree. This file is put into
the directory "user_com:" If you use a different name, or a different
directory, you will need to edit the recursive call near the bottom.

Cheers.

		Marty Sasaki

-------------------- cut here --------------------
$ !
$ ! D E L D I R . C O M - This command procedure asks for a root directory
$ !             and then deletes the entire directory structure.
$ !
$       if p1 .nes. "" then goto skip_inquiry
$       if p1 .eqs. "" then inquire p1 "_Root Directory to delete"
$ !
$ skip_inquiry:
$       root_dir :='p1
$       delete := "delete/nolog/noconfirm"
$       on warning then goto abort
$ !
$ main_loop:
$       any_dirs := "''root_dir'*.dir"
$       next_dir :='f$search(any_dirs)
$       if next_dir .eqs. "" then goto wipe_the_root
$       ptr :='f$locate("]",next_dir)
$       ptr = ptr + 1
$       length :='f$length(next_dir)
$       length = length - ptr
$       next_dir :='f$extract(ptr,length,next_dir)
$       ptr := 'f$locate(".", next_dir)
$       next_dir :='f$extract(0,ptr,next_dir)
$       next_dir = root_dir - "]" + "." + next_dir +"]"
$       @user_com:deldir.com 'next_dir'
$       goto main_loop
$ !
$ wipe_the_root:
$       any_files := "''root_dir'*.*;*"
$       write sys$output "...Deleting files in ''root_dir'"
$       if f$search(any_files) .nes. "" then delete 'any_files'
$ !
$ abort: