'This program finds numbered file overruns. 'It is designed to be used for programs such as Eudora which ammend the filenames 'of attachments by appending a numerical counters. In the case of excessive spam, 'these counters can overflow and damage the filesystem or Eudora's ability to 'process subsequent emails. %MAXFILES = 50000 DEFLNG a - z DECLARE SUB BreakFile(fullFile$, justName$, justExt$, justNum$) 'break a filename down into its component parts DECLARE FUNCTION IsNum(char$) 'Returns true if the character is a number (including zero) FUNCTION PBMAIN STDOUT "NUMFODS - Numbered file overrun detection system" STDOUT STDOUT "Report for: " & CURDIR$ DIM DirList$(1 TO %MAXFILES, 1 TO 4) numFiles = 0 x$ = DIR$("*.*") DO UNTIL x$ = "" INCR numFiles DirList$(numFiles, 1) = x$ BreakFile DirList$(numFiles, 1), DirList$(numFiles, 2), DirList$(numFiles, 3), DirList$(numFiles, 4) x$ = DIR$ IF numFiles = %MAXFILES THEN STDOUT "WARNING: " & FORMAT$(numFiles, ",") & " files reached; ignoring remainder." STDOUT END IF LOOP STDOUT "Analyzing " & FORMAT$(numFiles, ",") & " file(s) for numbering overruns." STDOUT numOver = 0 FOR r = 1 TO numFiles thisover = 0 FOR t = r + 1 TO numfiles IF LEN(DirList$(t, 2)) <> 0 THEN IF DirList$(t, 2) = DirList$(r, 2) AND DirList$(t, 3) = DirList$(r, 3) THEN 'same name, ext INCR thisover DirList$(t, 2) = "" DirList$(t, 3) = "" END IF END IF NEXT IF thisover <> 0 THEN INCR numOver DirList$(r, 4) = "match " & FORMAT$(thisover) END IF NEXT IF numOver > 0 THEN STDOUT FORMAT$(numOver, ",") & " overrun(s) found:" DIM Oversize(1 TO numOver) DIM Overname$(1 TO numOver) overat = 0 FOR r = 1 TO numFiles IF LEFT$(DirList$(r, 4), 5) = "match" THEN INCR overat Oversize(overat) = VAL(MID$(DirList$(r, 4), 7)) Overname$(overat) = DirList$(r, 2) & "*." & DirList$(r, 3) END IF NEXT ARRAY SORT Oversize() FOR overat, DESCEND, TAGARRAY Overname$() STDOUT STDOUT " REPS. FILENAME" STDOUT " ----- ----------" FOR r = 1 TO overat reps$ = SPACE$(5) RSET reps$ = FORMAT$(Oversize(r)) STDOUT " " & reps$ & " " & Overname$(r) NEXT ELSE STDOUT "No overruns found." END IF STDOUT END FUNCTION SUB BreakFile(fullFile$, justName$, justExt$, justNum$) 'break a filename down into its component parts lastperiod = INSTR(-1, fullFile$, ".") IF lastperiod = 0 THEN justName$ = LCASE$(fullFile$) justExt$ = "" ELSE justName$ = LCASE$(LEFT$(fullFile$, lastperiod - 1)) justExt$ = LCASE$(MID$(fullFile$, lastperiod + 1)) END IF justNum$ = "" DO IF IsNum(RIGHT$(justName$, 1)) = 1 THEN justNum$ = RIGHT$(justName$, 1) & justNum$ IF LEN(justName$) > 1 THEN justName$ = LEFT$(justName$, LEN(justName$)-1) ELSE justName$ = "" EXIT DO END IF ELSE EXIT DO END IF LOOP END SUB FUNCTION IsNum(char$) 'Returns true if the character is a number (including zero) ascii = ASC(char$) IF ascii >= 48 AND ascii <= 57 THEN FUNCTION = 1 ELSE FUNCTION = 0 END IF END FUNCTION