sqrkl@csvax.liv.ac.uk (03/07/88)
Having noticed a recursive directory-removing command file, here's my version (which I think is better, so there !) : Define the symbol REMDIR to point to this COM file (it MUST be the symbol REMDIR, because it uses this symbol to recursively call itself). --------------Cut out everything up to and including this line-------------- $ ! REMDIR utility (C) Richard K. Lloyd 1987 (Version 2.1 : 10/2/87) $ SET NOVERIFY $ IF F$ENVIRONMENT("DEPTH").NE.1 THEN $ GOTO NOTTOP $ OLDDIR == F$ENVIRONMENT("DEFAULT") $ SCARED == 0 $ ALLFILES == 0 $ IF P2.EQS."ALL" THEN $ ALLFILES == 1 $ NOTTOP: $ FRED = "" $ ON CONTROL_Y THEN $ GOTO CHICKEN $ DEPROT := SET PROT=(O:D) $ EXPLAIN = "Sub-directory" $ JOHN = "_""" + EXPLAIN + """" $ GETSUBDIR: $ IF P1.EQS."" THEN $ INQUIRE P1 'JOHN' $ IF P1.EQS."" THEN $ GOTO GETSUBDIR $ KILLDIR = P1 $ FULLDIR = "''P1'.DIR" $ EXTEND = F$LOCATE(".DIR",P1) $ IF EXTEND.EQ.F$LENGTH(P1) THEN $ GOTO NOEXT $ FULLDIR = KILLDIR $ KILLDIR = F$EXTRACT(0,EXTEND,P1) $ NOEXT: $ FULLNAME = EXPLAIN + " " + KILLDIR $ IF F$SEARCH(FULLDIR).EQS."" THEN $ GOTO NOSUCHDIR $ SET DEF [.'KILLDIR'] $ NUM = 0 $ CONTEXT = 0 $ NEXTFILE: $ FILE = F$SEARCH("*.*;*",CONTEXT) $ IF FILE.EQS."" THEN $ GOTO DELDIR $ IF NUM.NE.0.OR.ALLFILES.EQ.1 THEN $ GOTO NONZERO $ JOHN = "Do you REALLY want to remove " + FULLNAME + " (Y/N/ALL) ?" $ JOHN = """" + JOHN + """" $ DIR/WIDTH=(FILENAME=19)/NOTRAILING/COL=4 $ TYPE SYS$INPUT $ INQUIRE/NOPUNC FRED 'JOHN' $ IF FRED.NES."ALL" THEN $ GOTO CHICKEN $ ALLFILES == 1 $ NONZERO: $ NUM = NUM + 1 $ IF F$PARSE(FILE,,,"TYPE").NES.".DIR" THEN $ GOTO NEXTFILE $ 'REMDIR' 'F$PARSE(FILE,,,"NAME") $ IF SCARED.EQ.0 THEN $ GOTO NEXTFILE $ EXIT $ CHICKEN: $ IF FRED.EQS."Y" THEN $ GOTO NONZERO $ WRITE SYS$OUTPUT "REMDIR command aborted." $ SET DEFAULT 'OLDDIR' $ SCARED == 1 $ EXIT $ DELDIR: $ SET DEF [-] $ IF NUM.EQ.0 THEN $ GOTO REMOVE $ ALL = "[.''KILLDIR']*.*;*" $ IF F$SEARCH(ALL).EQS."" THEN $ GOTO REMOVE $ DEPROT 'ALL $ DELETE/NOCONF 'ALL $ WRITE SYS$OUTPUT "All files in ",FULLNAME, " have been deleted." $ REMOVE: $ DEPROT 'FULLDIR' $ DELETE/NOCONF 'FULLDIR'; $ WRITE SYS$OUTPUT FULLNAME, " has been deleted." $ EXIT $ NOSUCHDIR: $ WRITE SYS$OUTPUT FULLNAME," is not present." $ EXIT --------------Cut out everything after and including this line-------------- Below is some HELP (for inclusion into a HELP/LIBRARY system) for the REMDIR command : -----------Start of HELP----------- 1 REMDIR REMDIR removes a VMS sub-directory without the normal hassle. If any files are present in the sub-directory, they will be listed and you will be prompted for deletion. If you confirm the command, all the files inside the sub-directory will be deleted before the sub-directory itself is removed. Latest addition : ALL option (prompted from inside REMDIR or specified from DCL) will suppress deletion confirmation. Format: REMDIR sub-directory [ALL] 2 Examples $ REMDIR _Sub-directory: BAS Directory UMTOP:[UMBLOGGS.BAS] COUNT.BAS;1 COUNT.EXE;1 COUNT.OBJ;1 TEST.BAS;1 TEST.EXE;1 Do you REALLY want to remove Sub-directory BAS (Y/N/ALL) ?Y All files in Sub-directory BAS have been deleted. Sub-directory BAS has been deleted. $ REMDIR HELLO Sub-directory HELLO is not present. $ REMDIR BASIC Sub-directory BASIC has been deleted. ( No files were present in [.BASIC] in above example ) $ REMDIR PASCAL Directory UMTOP:[UMBLOGGS.PASCAL] COUNT.EXE;1 COUNT.PAS;1 SOURCE.DIR;1 Do you REALLY want to remove Sub-directory PASCAL (Y/N/ALL) ?Y Directory UMTOP:[UMBLOGGS.PASCAL.SOURCE] COUNT.BAK;1 Do you REALLY want to remove Sub-directory SOURCE (Y/N/ALL) ?Y All files in Sub-directory SOURCE have been deleted. Sub-directory SOURCE has been deleted. All files in Sub-directory PASCAL have been deleted. Sub-directory PASCAL has been deleted. $ REMDIR PROGGIES Directory UMTOP:[UMBLOGGS.PROGGIES] PROGGIE1.FOR;1 PROGGIE2.BAS;1 PROGGIE3.PAS;1 ANNOY.DIR;1 Do you REALLY want to remove Sub-directory PROGGIES (Y/N/ALL) ?N REMDIR command aborted. ( If N entered at ANY Y/N/ALL prompt, then REMDIR is immediately exited, WITHOUT REMOVING any sub-directories. N.B. Pressing CTRL-Y at the prompt is the same as entering N. ) $ REMDIR THINGIES Directory UMTOP:[UMBLOGGS.THINGIES] THINGIE1.DIR;1 THINGIE2.DIR;1 Do you REALLY want to remove Sub-directory THINGIES (Y/N/ALL) ?ALL All files in Sub-directory THINGIE1 have been deleted. Sub-directory THINGIE1 has been deleted. Sub-directory THINGIE2 has been deleted. All files in Sub-directory THINGIES have been deleted. Sub-directory THINGIES has been deleted. ( If ALL entered at ANY Y/N/ALL prompt, then REMDIR will not prompt for deletion from then on. ) $ REMDIR THINGIES.DIR ALL All files in Sub-directory THINGIE1 have been deleted. Sub-directory THINGIE1 has been deleted. Sub-directory THINGIE2 has been deleted. All files in Sub-directory THINGIES have been deleted. Sub-directory THINGIES has been deleted. This concludes a rather massive overkill of REMDIR examples. -----------------End of HELP------------- Hope you like this command...I may improve it further if there's any demand. Richard K. Lloyd, *************************************************** Computer Science Dept., * JANET : SQRKL@UK.AC.LIV.CSVAX * Liverpool University, * UUCP : {backbone}!mcvax!ukc!mupsy!liv-cs!SQRKL * Merseyside, England, * ARPA : SQRKL%csvax.liv.ac.uk@nss.cs.ucl.ac.uk * Great (?) Britain. *************************************************** "I have VERY strong opinions which are nothing whatsoever to do with the University of Liverpool, so blame ME if I bitch about useless IBM PC clones, even more redundant IBM mainframes and the terrible Atari ST..."