'===========================================================================
' Subject: ZAP CERTAIN .ZIPPED FILES          Date: 06-03-99 (11:16)       
'  Author: David A. Wicker                    Code: QB, QBasic, PDS        
'  Origin: topaz817@fastlane.net            Packet: MISC.ABC
'===========================================================================
' * Zap Zip!  Written by David A. Wicker
' ---------------------------------------------------------------------------
' As always, if you borrow anything from any source code for your
' shareware or freeware projects, please give credit to the original author!
' ---------------------------------------------------------------------------
' Note!  This program is not really meant as a tutorial in good programming,
' more it is useful for its function and purpose.

DEFINT A-Z
'$DYNAMIC
DECLARE SUB CRAbort ()

DEF FNPad$ (A$, A) = A$ + SPACE$(A - LEN(A$))

CLS
LOCATE 24
COLOR 14
PRINT "Zap*Zip >>> Written by David A. Wicker"
PRINT
COLOR 7
PRINT "* This program requires PKZIP v2.04g"
PRINT
COLOR 12
PRINT "NOTE!  This program is making precious few error checks on anything!"
PRINT "I assume no responsibility for any damage occuring with this"
PRINT "software.  Use at your own risk!"
COLOR 7
PRINT
INPUT "[ENTER] OR [Q]:", K$
IF K$ > "" THEN END
CLS
LOCATE 24
PRINT "Option #1:"
PRINT "Will wipe every single file PKZIPped in all PKZIPS located in THIS"
PRINT "directory with the exception of a list of EXCLUSIONS, (wildcard"
PRINT "character '*' acceptable!) you input below this."
PRINT "If an occurance cannot be found, that PKZIP will be ERASED completely."
PRINT "I.E.: *.TTF   will delete everything EXCEPT the *.TTF in the PKZIPs."
PRINT "!! This is a dangerous option and should be used carefully!"
PRINT "It is used mostly to remove extraneous data files and advertisements"
PRINT "from multiple archived PKZIP files where only the included data is desired."
PRINT
PRINT "Option #2:"
PRINT "This is easier to understand and safer to use."
PRINT "The text you input below will use that as"
PRINT "a file mask, (wildcard character '*' acceptable!) and delete just"
PRINT "those occurances inside every single PKZIP located in THIS directory."
PRINT "If an occurance cannot be found, no changes will occur with that file."
PRINT "I.E.: *.TXT   will delete every single *.TXT inside the PKZIPs."
CRAbort
PRINT
INPUT "Which activity do you want"; N
IF N <= 0 OR N >= 3 THEN
  CLS
  LOCATE 24
  PRINT "Perhaps a better understanding of DOS is needed.  :)"
  END
END IF

PRINT
PRINT
IF N = 1 THEN
  PRINT "Enter in the EXCLUSION data to save.  Multiple entries okay!"
  PRINT "I.E.: *.GIF *.JPG *.PCX   will retain JUST these files in all local PKZIPs."
  PRINT "Remember, if none of these extensions exist, that PKZIP will be ERASED!"
  CRAbort
  PRINT
  INPUT "Exclusion Data:", I$
ELSE
  PRINT "Enter in the INCLUSION data to remove.  Multiple entries okay!"
  PRINT "I.E.: *.TXT *.DOC   will remove JUST these files in all local PKZIPs."
  CRAbort
  INPUT "Inclusion Data:", I$
END IF
IF I$ = "" THEN END
PRINT
PRINT "Just a moment ..."
SHELL "dir/b *.zip>dir.___"
OPEN "i", 1, "dir.___"
WHILE EOF(1) = 0
  LINE INPUT #1, T$
  N& = N& + 1
WEND
CLOSE
PRINT
PRINT N&; " PKZIPs found."
PRINT
INPUT "Type in 'GO' to begin, or anything else to abort: ", G$
G$ = UCASE$(G$)
IF G$ <> "GO" THEN
  KILL "dir.___"
  END
END IF
PRINT
PRINT "We are ready to Begin!"
PRINT "During its operation, you can hit any key to pause."
PRINT
INPUT "press [ENTER] to start activity on all PKZIPs.", K$
OPEN "i", 1, "dir.___"
WHILE EOF(1) = 0
  LINE INPUT #1, F$
  PRINT UCASE$(FNPad$(F$, 12));
  IF INKEY$ > "" THEN
    PRINT "* Pause!"
    PRINT
    PRINT "[C]ontinue"
    PRINT "[E]nd"
    DO: LOOP UNTIL INKEY$ = ""
    INPUT ":", K$
    K$ = UCASE$(K$)
    IF K$ = "E" THEN
      KILL "dir.___"
      PRINT "* Remaining Tasks Aborted!"
      END
    END IF
  END IF
  IF N = 1 THEN
    SHELL "pkzip -d " + F$ + " *.* -x" + I$ + ">nul"
  ELSE
    SHELL "pkzip -d " + F$ + " " + I$ + ">nul"
  END IF
  OPEN "a", 2, F$
  IF LOF(2) = 22 THEN
    PRINT "* Erased!"
    CLOSE 2
    KILL F$
  ELSE
    CLOSE 2
    PRINT "> Okay!"
  END IF
WEND
CLOSE
PRINT
PRINT "* Complete!"
KILL "dir.___"
END

REM $STATIC
SUB CRAbort
  PRINT
  PRINT "press [ENTER] by itself to abort."
END SUB
