home *** CD-ROM | disk | FTP | other *** search
- Title ZDEL: multiple file deletion utility
-
- comment !
- ZDEL v3.001 for the Public Domain
-
- Thomas Hanlin III
- 6812 Sydenstricker Rd
- Springfield, VA 22152
-
- Update notes: v2.0 allows full path specs with filenames.
- v3.0 includes more information in the confirmation.
- v3.001 fixes a minor bug that caused the "days" portion
- of dates from months > 9 to be displayed incorrectly
- (Mike Pechnyo, 5-4-87)
- !
-
-
- Sseg segment byte stack 'prog' ; dummy stack segment
- Sseg ends
-
-
- Cseg segment byte public 'prog'
- assume cs:Cseg, ds:Cseg, ss:Sseg
-
- org 80h
- CMDLEN db ?
- CMDINFO db 127 dup(?)
-
- org 100h
-
- MAIN proc far
- xor cx,cx ; clear parm length
- mov cl,CMDLEN
- mov PARMLEN,cl
- jcxz Inform
- mov si,offset CMDINFO
- mov di,offset PARMINFO
- mov PARMLOC,di
-
- cld
- SaveParms: lodsb ; get a command-line char
- cmp al,"/" ; is it a switch?
- jne NotSwitch ; no, skip switch handler
- Switches: lodsb ; get the switch char
- and al,11011111b ; convert to uppercase
- cmp al,"K" ; K>ill without confirmation?
- je SwitchKill ; yes, set flags
- cmp al,"S" ; S>hort confirm?
- jne Inform ; no, list valid parms
- mov byte ptr SHORTCNF,1
- jmp short SwitchDone
- SwitchKill: mov byte ptr CONFIRM,0 ; set confirmation off
- SwitchDone: sub byte ptr PARMLEN,2 ; remove "-K" from parms
- loop SP_loop
- jmp short Inform ; oops, no letter, so error!
- NotSwitch: stosb ; save it as a parm chr
- SP_loop: loop SaveParms ; scan entire command line
- cmp byte ptr PARMLEN,0 ; doublecheck parms
- jz Inform ; Inform if switch w/o filespec
- inc byte ptr PARMLEN ; account for later decrement
-
- GetParm: xor cx,cx
- mov cl,PARMLEN ; get parm length
- jcxz Done ; exit if no more files to kill
- dec cx ; factor in space between parms
- jcxz Done ; exit if no more files to kill
- mov si,PARMLOC ; get parm location
- cld ; search forward
- SeekParmStart: cmp byte ptr [si]," " ; is it a valid char?
- jne GotStart ; yes, go handle it
- inc si ; move to next char
- loop SeekParmStart ; loop until start of parm
-
- Inform: mov dx,offset ZDELINFO
- mov ah,9
- int 21h
- Done: int 20h ; exit program
-
- GotStart: mov dx,si ; point to start of parm
- cld ; set direction forward
- SeekParmEnd: lodsb ; get a parm char
- cmp al," " ; is it a space?
- je GotParmEnd
- loop SeekParmEnd ; loop if not
- GotParmEnd: mov PARMLEN,cl ; save new parm line length
- jcxz GotParm
- mov PARMLOC,si ; and new location
- dec si ; go back to space
- GotParm: mov [si],ch ; put filespec in ASCIIZ format
- mov di,offset FILESPEC +65 ; end of path area
- std ; set direction backwards
- dec si ; move to last chr of filespec
-
- SeekPath: lodsb ; get a chr
- cmp al,":" ; are we back at the drive spec?
- je SavePath ; yes, save it
- cmp al,"\" ; are we back at the subdir spec?
- je SavePath ; yes, save it
- cmp al," " ; are we back at the start?
- je GotPath ; yes, null path
- or al,al ; are we back at the previous file?
- jnz SeekPath ; no, go until we find something
- jmp short GotPath ; null path spec
-
- SavePath: cmp al,"a" ; is it lowercase?
- jb UpCase ; no
- cmp al,"z" ; is it really lowercase?
- ja UpCase ; no
- sub al,32 ; convert it to uppercase
- UpCase: stosb ; save path chr
- lodsb ; get another path chr
- or al,al ; are we back at the previous file?
- jz GotPath ; yes, we're done saving the path
- cmp al," " ; are we back at the beginning?
- jnz SavePath ; no, keep saving path
-
- GotPath: inc di ; move to first chr of path spec
- mov FILELOC,di ; save location
- mov ah,4Eh ; find first file
- xor cx,cx ; seek normal files
- int 21h
- or ax,ax ; was there an error?
- jnz GetParm ; yes, try next parm
-
- XferName: mov si,offset CMDLEN +30 ; loc of filename
- mov di,offset FILESPEC +66 ; where to store it
- cld ; move forward
- mov cx,12 ; max chars per filename
- SaveName: lodsb ; get a chr of the filename
- or al,al ; end of filename?
- jz EndFileName ; yes, handle it
- stosb ; store chr
- loop SaveName ; transfer all of filename
- jmp short NoFill ; skip fill with blanks
- EndFileName: mov al," "
- rep stosb ; left-justify filename in blanks
- NoFill: xor al,al
- stosb
-
- cmp byte ptr CONFIRM,1 ; confirm deletion?
- je ConfirmIt ; yes, go confirm deletion
- jmp DeleteIt ; go delete file
-
- ConfirmIt: mov ah,9 ; display string
- mov dx,offset DELSTR1 ; "Delete "
- int 21h
-
- mov si,FILELOC ; get start of filespec
- DispPath: mov dl,[si] ; get a char
- or dl,dl ; is it null?
- jz CheckConfirm ; yep, go see how to confirm it
- mov ah,2 ; display char
- int 21h
- inc si
- jmp DispPath
-
- CheckConfirm: cmp byte ptr SHORTCNF,1 ; short confirmation?
- jne LongConfirm ; no, do size/date/time stuff
- jmp DispDelStr2 ; skip size/date/time...
-
- LongConfirm: mov ax,word ptr CMDLEN +26 ; lsw of file size
- mov dx,word ptr CMDLEN +28 ; msw of file size
- call ASCFileSize ; convert filesize to ASCII
-
- mov ax,word ptr CMDLEN +24 ; get file date
- mov si,offset DISPBUF +18 ; ofs of year in buffer
- mov dx,ax ; save date
- mov cl,9 ; shift for year
- shr ax,cl ; get year
- add ax,80 ; add bias
- cmp ax,100 ; is it two digits (1900's) ?
- jb ConvYear ; yes, go convert it
- sub ax,100 ; make it two digits (2000's)
- ConvYear: call TwoDigit ; convert to ASCII
- and dh,1 ; clear year from date
- mov ax,dx ; restore date
- mov cl,5 ; shift for month
- shr ax,cl ; get month
- mov si,offset DISPBUF +12 ; ofs of month in buffer
- call TwoDigit ; convert to ASCII
- mov ax,dx ; restore date
-
- ; and al,1Fh ; screen out month, leaving day
- and ax,1Fh ; screen out month, leaving day
- ; if AX is not masked, then there
- ; can be a 1 as the low bit of AH
- ; for months > 8, which screws up
- ; the display of the days
- ; ... Mike Pechnyo 5-4-87
-
- mov si,offset DISPBUF +15 ; ofs of day in buffer
- call TwoDigit ; convert to ASCII
-
- mov ax,word ptr CMDLEN +22 ; get file time
- mov dx,ax ; save time
- mov cl,11 ; shift for hour
- shr ax,cl ; get hour
- mov si,offset DISPBUF +22 ; ofs of hour in buffer
- call TwoDigit ; convert to ASCII
- mov ax,dx ; restore time
- mov cl,5 ; shift for minute
- shr ax,cl ; get minute
- and ax,3Fh ; screen out hour
- mov si,offset DISPBUF +25 ; ofs of minute in buffer
- call TwoDigit
-
- mov dx,offset DISPBUF ; location of display buffer
- mov ah,9 ; display string
- int 21h
-
- DispDelStr2: mov dx,offset DELSTR2 ; " [Y,N,Q] ? $"
- mov ah,9 ; display string
- int 21h
-
- GetKey: mov ah,8 ; keyboard input without echo
- int 21h
- or al,al ; extended ASCII?
- jnz GotKey ; no, process it
- mov ah,8 ; keyboard input (to junk extASCII)
- int 21h
- jmp GetKey ; go get a valid key this time
- GotKey: and al,11011111b ; convert key to uppercase
- cmp al,"Y" ; delete file?
- jne NotY ; no
- call DispLine ; display chr,CR,LF
- jmp short DeleteIt ; go delete file
- NotY: cmp al,"N" ; skip file?
- jne NotN ; no
- call DispLine ; display chr,CR,LF
- jmp short NextFile ; go skip file
- NotN: cmp al,"Q" ; quit program?
- jne GetKey ; no, go get a valid key
- call DispLine ; display chr,CR,LF
- jmp Done ; exit program
-
- DeleteIt: mov ah,41h ; delete file
- mov dx,FILELOC
- int 21h
-
- NextFile: mov ah,4Fh ; find next file
- int 21h
- or ax,ax ; was there an error?
- jnz BadFile ; yes, ignore it
- jmp XferName ; go buffer the filename
- BadFile: jmp GetParm ; skip to the next parm
- MAIN endp
-
-
- DispLine proc near
- mov bx,offset DELSTR3
- mov [bx],al
- mov dx,bx
- mov ah,9 ; display string
- int 21h
- ret
- DispLine endp
-
-
- ASCFileSize proc near ; file size in DX:AX --> ASCII number
- mov si,offset DISPBUF +1 ; where to put result
- mov di,offset CONVTABLE ; table of powers of ten
- mov byte ptr SHOWZERO,0 ; don't show leading zeroes
- AFS1: mov byte ptr DIGIT,0 ; clear digit
- mov cx,2[di] ; get table entry (msw)
- cmp cx,-1 ; at end of table?
- je AFSdone ; yes, we're done
- mov bx,[di] ; get table entry (lsw)
- AFS2: cmp dx,cx ; is number < table (msw)?
- jb AFS3 ; yes, got digit
- ja AFS2A ; ...get digit
- cmp ax,bx ; is number < table (lsw)?
- jb AFS3 ; yes, got digit
- AFS2A: inc byte ptr DIGIT ; increment digit
- sub ax,bx ; reduce number accordingly
- sbb dx,cx
- jmp AFS2 ; keep going on this digit
- AFS3: push ax ; save AX, we need it
- mov al,DIGIT ; get digit
- add al,"0" ; convert to ASCII
- cmp al,"0" ; is it zero?
- jz AFS5 ; yes, special case
- mov byte ptr SHOWZERO,1 ; show following zeroes
- AFS4: mov [si],al ; store digit
- pop ax ; restore AX
- inc si ; move to next buffer loc
- add di,4 ; move to next table loc
- jmp AFS1 ; convert until done
- AFSdone: ret
- AFS5: cmp SHOWZERO,1 ; show zeroes?
- je AFS4 ; yes
- mov al," " ; leading zeroes --> blanks
- jmp AFS4
- ASCFileSize endp
-
-
- TwoDigit proc near ; AX --> two-digit ASCII number
- mov cl,10 ; convert to base 10
- div cl
- add ax,3030h ; convert digits to ASCII
- mov [si],ax ; save result
- ret
- TwoDigit endp
-
-
-
- CONFIRM db 1 ; whether to confirm before deleting (default YES)
- SHORTCNF db 0 ; whether to use short confirmation (default NO)
- PARMLEN db 0 ; length of parms left to examine
- PARMLOC dw ? ; location of current parm item
- PARMINFO db 127 dup(0) ; cleaned-up command line storage
- FILELOC dw ? ; location of start of path spec in storage
- FILESPEC db 79 dup(0) ; full filespec storage
- DISPBUF db 9 dup(" "),"b 00/00/00 00:00 $" ; long confirm display buffer
-
- DELSTR1 db "Delete $"
- DELSTR2 db " [Y,N,Q]? $"
- DELSTR3 db "x",13,10,"$"
-
- CONVTABLE dd 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1, -1
- DIGIT db 0
- SHOWZERO db 0
-
- ZDELINFO db 13,10,"ZDEL 3.0 by Tom Hanlin for the Public Domain",13,10,10
- db "Purpose: multiple-file deletion utility with confirmation.",13,10
- db "Format : ZDEL [/K] [/S] [filename] [..filename]",13,10
- db "Options: Use /K to bypass confirmation before deletion.",13,10
- db " Use /S for short confirmation.",13,10
- db "$"
-
- Cseg ends
- end MAIN
-