$! DeleteDirTree.COM $! 3-SEP-1992 Mathog $! This procedure deletes a directory tree. It takes a single $! parameter which is the name of the top of the directory. $! $ set noon $ ws := write sys$output $ hit = "" $ if(P1 .nes. "")then goto gotp $ ws "Usage: @deletedirtree DISK:[DIR1.DIR2.DIR3]" $ ws " will delete the entire directory tree down from [.DIR3]" $ ws " and including the file DIR3.DIR;1" $ exit $gotp: $ FILE = P1 $ FBRACK = F$LOCATE("[",FILE) $ IF(FBRACK .ne. F$LENGTH(FILE))then goto next1 $ ws "Error in directory specification, no [" $ exit $next1: $ EBRACK = F$LOCATE("]",FILE) $ IF(EBRACK .ne. F$LENGTH(FILE))then goto next2 $ ws "Error in directory specification, no ]" $ exit $next2: $! $! if it's [dir] then put DIR] into FRAG and rewrite FILE as $! [000000.DIR] $! $ FRAG = F$EXTRACT(FBRACK+1,EBRACK-FBRACK-1,FILE) $ NDOT = F$LOCATE(".",FRAG) $ IF(NDOT .ne. F$LENGTH(FRAG))then goto loop0 $ FILE = F$EXTRACT(0,FBRACK+1,FILE) + "000000." + FRAG $GOTLAST: $ FRAG = FRAG + "]" $ GOTO PRELOOP $! $! if it's [dir1.dir2.dir3] then put DIR3 into FRAG and go on $! $LOOP0: $ NDOT = F$LOCATE(".",FRAG) $ IF(NDOT .eq. F$LENGTH(FRAG))then goto gotlast $ FRAG = F$EXTRACT(NDOT+1,F$LENGTH(FRAG),FRAG) $ GOTO LOOP0 $PRELOOP: $ FILE = FILE -"]" + "...]*.*;*" $ SET FILE/PROT=(S:RWED,O:RWED) 'FILE' $LOOP1: $ DELETE/LOG 'FILE' $ HIT = F$SEARCH (FILE,1) $ if(HIT .eqs. "")then goto LOOP2 $ GOTO LOOP1 $LOOP2: $ FILE = FILE - "...]*.*;*" + "]" $ HIT = F$LOCATE(FRAG,FILE) $ FILE = F$EXTRACT(0,F$LENGTH(FILE) - F$LENGTH(FRAG) - 1,FILE) $ FRAG = FRAG - "]" + ".dir;" $ FILE = FILE + "]" + FRAG $ SET FILE/PROT=(S:RWED,O:RWED) 'FILE' $ DELETE/LOG 'FILE' $EXIT