home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / DELDATE1.ZIP / DELDATE.CMD next >
OS/2 REXX Batch file  |  1993-03-21  |  5KB  |  1 lines

  1. /*A Command to Delete Files According to Date Stamps*/;arg PARMS;if (PARMS='')|(PARMS='?')|(PARMS='/?')|(PARMS='-?')|(translate(PARMS)='H')|(translate(PARMS)='/H')|(translate(PARMS)='-H') then call Syntax;do until PARMS='';parse var PARMS ONE PARMS;select;when (translate(ONE)='/Z')|(translate(ONE)='-Z') then ZAP=YES;when (translate(left(ONE,2))='/A')|(translate(left(ONE,2))='-A') then do;AFTER=space(translate(substr(ONE,3),'','-/'),0);if (datatype(AFTER)<>'NUM')|(length(AFTER)<>6) then call Syntax;end;when (translate(left(ONE,2))='/B')|(translate(left(ONE,2))='-B') then do;BEFORE=space(translate(substr(ONE,3),'','-/'),0);if (datatype(BEFORE)<>'NUM')|(length(BEFORE)<>6) then call Syntax;end;when (length(space(translate(ONE,'','-/'),0))=6)&(datatype(space(translate(ONE,'','-/'),0))='NUM') then ON=space(translate(ONE,'','-/'),0);when (pos('?',ONE)>0)|(pos('*',ONE)>0) then SPEC=ONE;otherwise call Syntax;end;end;if (ON<>'ON')&(((AFTER<>'AFTER')|(BEFORE<>'BEFORE'))) then call Syntax;if SPEC='SPEC' then SPEC='*.*';if ON<>'ON' then ON=right(ON,2)||left(ON,2)||substr(ON,3,2);if BEFORE<>'BEFORE' then BEFORE=right(BEFORE,2)||left(BEFORE,2)||substr(BEFORE,3,2);if AFTER<>'AFTER' then AFTER=right(AFTER,2)||left(AFTER,2)||substr(AFTER,3,2);if rxfuncquery(sysloadfuncs) then do;call rxfuncadd sysloadfuncs, rexxutil, sysloadfuncs;call sysloadfuncs;end;if ZAP='YES' then call sysfiletree SPEC,'FILES','FT','*-***';else call sysfiletree SPEC,'FILES','FT','*----';if FILES.0=0 then do;say "No files match" SPEC".";exit;end;TOTAL=0;do i=1 to FILES.0;DATEVAR=space(translate(left(word(FILES.i,1),8),'','/'),0);select;when (ON<>'ON')&(DATEVAR=ON) then nop;when (AFTER<>'AFTER')&(BEFORE<>'BEFORE')&(DATEVAR>=AFTER)&(DATEVAR<=BEFORE) then nop;when (AFTER<>'AFTER')&(BEFORE='BEFORE')&(DATEVAR>=AFTER) then nop;when (BEFORE<>'BEFORE')&(AFTER='AFTER')&(DATEVAR<=BEFORE) then nop;otherwise FILES.i='';end;if FILES.i<>'' then TOTAL=TOTAL+1;end;if TOTAL=0 then do;say "No files found that match date(s).";exit;end;call syscls;if TOTAL=1 then do;say "Found 1 file which matches your specification.";say "Permission to delete the following file?  (Y/N)";end;else do;say "Found" TOTAL "files which match your specification.";say "Permission to delete the following files?  (Y/N)";end;do i=1 to FILES.0;if FILES.i<>'' then do;if word(syscurpos(),1)>22 then do;say 'Press <enter> to continue.....';pull .;call syscls;end;DATEVAR=word(FILES.i,1);DATEVAR=substr(DATEVAR,4,2)'/'substr(DATEVAR,7,2)'/'left(DATEVAR,2);say "   "DATEVAR"   "word(FILES.i,4);end;end;if TOTAL>21 then say "Permission to delete?  (Y/N)";do until (ask='Y')|(ask='N');pull ask;end;if ask='N' then exit;TOTAL=0;do i=1 to FILES.0;if FILES.i<>'' then do;DELETE=sysfiledelete(word(FILES.i,4));if DELETE=0 then do;TOTAL=TOTAL+1;say "   Deleted" word(FILES.i,4);end;else say "      Cannot delete" word(FILES.i,4);end;end;if TOTAL=1 then say "      1 file deleted.";else say "      "TOTAL "files deleted.";say;say 'Copyright 03/20/93 by Kari Jackson.  Thank you for using DELDATE.';exit;Syntax:;say "DELDATE program Copyright 3/20/93 Kari Jackson.  If you like this program,";say "please consider sending me a dollar.   3201 Monroe,  Omaha NE 68107.   Use";say "this program at your own risk.  I am not responsible for any problems that";say "may be caused.   However, rest assured that I'm using it myself and giving";say "it to all of my best friends so obviously I trust that it's safe.  DELDATE";say "will NEVER  delete a file  without first asking  for permission  to delete";say "that specific file,  EVEN IF it could  POSSIBLY have bugs  in other areas.";say;say "Dates MUST be specified in the form MM/DD/YY.  / characters can be omitted";say "or replaced with - characters,  but the month must be first, the date must";say "be next and the year must be last,  and they must each be two digits long.";say "In other words 03/20/93, 03-20-93, 032093,  and even 03/20-93 are correct,";say "but 32093, 3-20-93, 93/03/20, and 20/3/93 will not work.";say;say "You may specify one WILDCARD filename such as C:\DIR\*.* or *.TXT.  If you";say "don't,  then DELDATE will assume *.* which means  all files in the current";say "directory.";say;say "/Z or -Z .............. Zap all files including hidden, system, read-only.";say "/Ammddyy or -Ammddyy ............... Delete files with this date or after.";say "/Bmmddyy or -Bmmddyy .............. Delete files with this date or before.";say "/Ammddyy /Bmmddyy .............. Delete files with these dates or between.";say "mmddyy ................................. Delete files with this date only.";exit;return;