'=========================================================================== ' Subject: ELIMINATE DUPES Date: Unknown Date (00:00) ' Author: Earl Montgomery Code: QB, PDS ' Keys: ELIMINATE,DUPES Packet: DOS.ABC '=========================================================================== 'This program finds duplicates in the selected directories and 'gives you the oppurtunity to delete. It can also work on just 'one directory and allow you to delete files within that 'directory. I think it is pretty neat. Try it out. '---- DOCS FOR ELIMDUPE.BAS ' 'If you program alot as I do, at the end of the day you have probably 'created quite a few duplicate files. And after several days you 'really have a mess on your hands. For example I have a seperate 'QB source file directory (QBSOURCE). And I am constantly moving 'files back and forth between QBSOURCE and QB45. Well this is where 'ELIMDUPE comes in handy. It will delete these files in a hurry! 'I prefer to use utility programs written in a language I understand, 'provided I have the source code - which you do! I prefer this 'because if I locate a bug I can fix it. And if I decide to add a 'few new features I can do that too. ' 'Comments: The program is so easy to use this DOC file really isn't 'necessary. However there are a couple of things you need to know. ' '#1. You can select the root directory from your hard drive by ' pressing at any directory prompt. ' '#2. When prompted to decide whether or not to delete a file ' pressing is the same as "N" and takes you to the ' next duplicate. ' '#3. You can also use this program to delete files in only one ' directory. To do this just enter the same directory name ' for both selections (directory #1 and directory #2). ' 'If you find any bugs please let me know! Especially if you have 'fixed them! . 'Credits: Thanks to Tim Fitzgerald, Dick Dennison and Mike Herbert ' for their help with the interrupts. ' Special thanks to Tim Berneman as I hacked some of his ' interrupt code from BDIR.BAS '$INCLUDE: 'qb.bi' DEFINT A-Z DIM f1.nam$(500) 'Make as large as you need DIM f2.nam$(500) DIM f1.name$(500) DIM f2.name$(500) drive$ = "C:\" ON ERROR GOTO fatalerror KEY(10) ON ON KEY(10) GOSUB exitroutine DIM inregs AS regtypex, outregs AS regtypex REM Saving the current directory tempdir$ = STRING$(64, " ") inregs.es = -1 inregs.ax = &H4700 inregs.dx = 0 inregs.ds = VARSEG(tempdir$) inregs.si = SADD(tempdir$) CALL interruptx(&H21, inregs, outregs) tempdir$ = LEFT$(tempdir$, INSTR(tempdir$, CHR$(0)) - 1) restart: CLS DEF SEG = &HB800 COLOR 14 POKE 0, 201 FOR x = 2 TO 158 STEP 2: POKE x, 205: NEXT POKE 158, 187 FOR x = 160 TO 3880 STEP 160: POKE x, 186: NEXT POKE 3840, 200 FOR x = 3842 TO 4000 STEP 2: POKE x, 205: NEXT FOR x = 3998 TO 160 STEP -160: POKE x, 186: NEXT POKE 3998, 188 DEF SEG firstinput: LOCATE 2, 30: PRINT "Eliminate Dupes" LOCATE 3, 28: PRINT "By Earl Montgomery" LOCATE 4, 20: PRINT "Written entirely in Quick Basic 4.5" LOCATE 6, 15: PRINT "Press at any directory prompt for C:\" LOCATE 10, 4: PRINT STRING$(40, " ") LOCATE 11, 4: PRINT STRING$(40, " ") LOCATE 10, 4: INPUT "Name of first directory"; n1$ n1$ = UCASE$(n1$) path$ = drive$ + n1$ + CHR$(0) REM changing directories inregs.es = -1 inregs.ax = &H3B00 inregs.ds = VARSEG(path$) inregs.dx = SADD(path$) CALL interruptx(&H21, inregs, outregs) IF outregs.ax = 3 THEN GOSUB invaliddirectory1: GOTO firstinput GOSUB begin secondinput: LOCATE 10, 4: PRINT STRING$(40, " ") LOCATE 11, 4: PRINT STRING$(40, " ") LOCATE 10, 4: INPUT "Name of second directory"; n2$ n2$ = UCASE$(n2$) path$ = drive$ + n2$ + CHR$(0) inregs.es = -1 inregs.ax = &H3B00 inregs.ds = VARSEG(path$) inregs.dx = SADD(path$) CALL interruptx(&H21, inregs, outregs) IF outregs.ax = 3 THEN GOSUB invaliddirectory2: GOTO secondinput GOSUB lookfordupes begin: de1 = 0 filespec$ = "*.*" + CHR$(0) inregs.ax = &H2F00 CALL interruptx(&H21, inregs, outregs) data.seg = outregs.es data.off = outregs.bx inregs.ax = &H4E00 inregs.dx = SADD(filespec$) inregs.ds = -1 CALL interruptx(&H21, inregs, outregs) cy = outregs.flags AND 1 IF cy = 0 THEN END IF WHILE cy = 0 DEF SEG = data.seg f1.name$ = "" i = data.off + 30 WHILE PEEK(i) <> 0 f1.name$ = f1.name$ + CHR$(PEEK(i)) i = i + 1 WEND DEF SEG de1 = de1 + 1 f1.nam$(de1) = f1.name$ inregs.ax = &H4F00 CALL interruptx(&H21, inregs, outregs) cy = outregs.flags AND 1 WEND IF i = 0 THEN END IF RETURN lookfordupes: de2 = 0 filespec$ = "*.*" + CHR$(0) inregs.ax = &H2F00 CALL interruptx(&H21, inregs, outregs) data.seg = outregs.es data.off = outregs.bx inregs.ax = &H4E00 inregs.dx = SADD(filespec$) inregs.ds = -1 CALL interruptx(&H21, inregs, outregs) cy = outregs.flags AND 1 IF cy = 0 THEN END IF WHILE cy = 0 DEF SEG = data.seg f2.name$ = "" i = data.off + 30 WHILE PEEK(i) <> 0 f2.name$ = f2.name$ + CHR$(PEEK(i)) i = i + 1 WEND DEF SEG de2 = de2 + 1 f2.nam$(de2) = f2.name$ inregs.ax = &H4F00 CALL interruptx(&H21, inregs, outregs) cy = outregs.flags AND 1 WEND IF i = 0 THEN END IF IF de1 > de2 THEN endofloop = de1: ELSE endofloop = de2 FOR x = 1 TO endofloop FOR Y = 1 TO endofloop IF f1.nam$(x) = f2.nam$(Y) THEN GOSUB duplicatefound NEXT: NEXT GOTO exitorcontinue delete: tryagain: LOCATE 10, 4: PRINT STRING$(40, " ") LOCATE 11, 4: PRINT STRING$(40, " ") LOCATE 12, 4: PRINT STRING$(40, " ") LOCATE 10, 4: PRINT "(1) "; n1$; : PRINT " (2) " + n2$ LOCATE 11, 4: PRINT "Duplicate File Name "; : PRINT f1.nam$(x) LOCATE 12, 4: INPUT "From which directory (1 or 2)"; dn IF dn = 1 THEN path$ = drive$ + n1$ + CHR$(0) IF dn = 2 THEN path$ = drive$ + n2$ + CHR$(0) IF dn <> 1 AND dn <> 2 THEN BEEP: GOTO tryagain inregs.es = -1 inregs.ax = &H3B00 inregs.ds = VARSEG(path$) inregs.dx = SADD(path$) CALL interruptx(&H21, inregs, outregs) KILL temp$ RETURN fatalerror: BEEP: CLS PRINT "Error is code "; : PRINT ERR PRINT "Fatal error returning to DOS" SLEEP (2) path$ = drive$ + tempdir$ + CHR$(0) inregs.es = -1 inregs.ax = &H3B00 inregs.ds = VARSEG(path$) inregs.dx = SADD(path$) CALL interruptx(&H21, inregs, outregs) CLS : SCREEN 0: SYSTEM duplicatefound: LOCATE 10, 4: PRINT STRING$(40, " ") LOCATE 11, 4: PRINT STRING$(40, " ") LOCATE 12, 4: PRINT STRING$(40, " ") IF n1$ = "" THEN LOCATE 10, 4: PRINT "C:\" ELSE LOCATE 10, 4: PRINT n1$; IF n2$ = "" THEN LOCATE 10, 20: PRINT "C:\" ELSE LOCATE 10, 20: PRINT n2$ LOCATE 11, 4: PRINT f1.nam$(x); : LOCATE 11, 20: PRINT f2.nam$(Y) temp$ = f1.nam$(x) LOCATE 12, 4: INPUT "Delete one of these files"; q$ q$ = UCASE$(q$): IF q$ = "Y" THEN GOTO delete: ELSE RETURN exitorcontinue: CLS PRINT "No duplicates found or all duplicates have been processed." INPUT "Do you wish to check other directories"; q$ q$ = UCASE$(q$) IF q$ = "Y" THEN CLS : GOTO prepareforrestart IF q$ = "N" THEN GOTO exitroutine GOTO exitorcontinue exitroutine: path$ = drive$ + tempdir$ + CHR$(0) inregs.es = -1 inregs.ax = &H3B00 inregs.ds = VARSEG(path$) inregs.dx = SADD(path$) CALL interruptx(&H21, inregs, outregs) CLS : SCREEN 0: SYSTEM prepareforrestart: FOR x = 0 TO 500 f1.nam$(x) = "" f2.nam$(x) = "" f1.name$(x) = "" f2.name$(x) = "" NEXT n1$ = "" 'm2$ = "" n2$="" 'I just noticed that in the last part of ELIMDUPE.BAS (part 4 of 4) 'that there is a mistake in the sub PREPARETORESTART: 'The line that reads: 'm2$="" should read n2$="". 'However it runs fine as it is but thought I'd better pass it along. 'Earl de1 = 0: de2 = 0 path$ = "" temp$ = "" GOTO restart invaliddirectory1: LOCATE 11, 4 PRINT "Invalid Directory" SLEEP (1) RETURN invaliddirectory2: LOCATE 11, 4 PRINT "Invalid Directory" SLEEP (1) RETURN