DEFLNG a-z 'wfdir %MAXFILES = 250000 FUNCTION PBMAIN STDOUT "wfdir" STDOUT "Work From Directory" STDOUT STDOUT "This file applies commands to files inside a DIR command that's" STDOUT "been piped to a file." STDOUT STDOUT "Input DIR file --> "; STDIN LINE inputfile$ IF TRIM$(inputfile$) = "" OR INSTR(inputfile$, ANY "*?") OR DIR$(inputfile$) = "" THEN STDOUT STDOUT "Must enter a file that exists..." STDOUT "Aborted!" STDOUT EXIT FUNCTION END IF STDOUT "Create a command, with *file* substituting for the filename." STDOUT "Command --> "; STDIN LINE thecommand$ IF INSTR(thecommand$, "*file*") < 1 THEN STDOUT STDOUT "Must enter a command..." STDOUT "Aborted!" STDOUT EXIT FUNCTION END IF STDOUT STDOUT "Processing now" DIM filelist$(1 TO %MAXFILES) numfiles = 0 currentdir$ = "" OPEN inputfile$ FOR INPUT AS #1 DO UNTIL EOF(1) LINE INPUT #1, x$ x$ = TRIM$(x$) IF LEFT$(x$, 12) = "Directory of" THEN currentdir$ = MID$(x$, 14) ELSEIF LEN(x$) > 39 THEN tim$ = MID$(x$, 19, 2) IF (tim$ = "AM" OR tim$ = "PM") AND MID$(x$, 25, 5) <> "" THEN INCR numfiles filelist$(numfiles) = currentdir$ & "\" & MID$(x$, 40) END IF END IF IF numfiles >= %MAXFILES THEN STDOUT "WARNING: Too many files!" STDOUT " Only processing first " & FORMAT$(%MAXFILES) EXIT DO END IF LOOP CLOSE #1 STDOUT STDOUT FORMAT$(numfiles) & " files found in DIR." STDOUT STDOUT "Output file --> "; STDIN LINE outputfile$ IF TRIM$(outputfile$) = "" THEN STDOUT STDOUT "Must enter a file..." STDOUT "Aborted!" STDOUT EXIT FUNCTION END IF OPEN outputfile$ FOR OUTPUT AS #1 FOR r = 1 TO numfiles thiscmd$ = thecommand$ REPLACE "*file*" WITH filelist$(r) IN thiscmd$ PRINT #1, thiscmd$ NEXT CLOSE #1 END FUNCTION