'rWrap - recursive command wrapper for Windows command prompts. Should work ' on any version on Windows on up from 95. 'by Shannon Larratt - glider@bmezine.com 'This is free software. Copy it. Use it. Sell it. Edit it. Doesn't matter to me. 'Oh yeah, and use at your own risk. DEFLNG a-z 'yeah, I'm lazy. so what FUNCTION PBMAIN() thiscmd$ = TRIM$(COMMAND$) STDOUT "rWrap - Recursive command wrapper" STDOUT firstspace = INSTR(thiscmd$, " ") IF thiscmd$ = "" OR firstspace = 0 THEN STDOUT "Usage: rWrap filemask command [/file] [-nowait]" STDOUT " ie. rWrap *.ini move /file \myinis" STDOUT " rWrap *.txt notepad /file -nowait" STDOUT EXIT FUNCTION END IF filemask$ = MID$(thiscmd$, 1, firstspace-1) thecommand$ = LTRIM$(MID$(thiscmd$, firstspace+1)) nowait = 0 IF INSTR(thecommand$, "-nowait") > 0 THEN nowait = 1 thecommand$ = TRIM$(REMOVE$(thecommand$, "-nowait")) END IF goback$ = CURDIR$ 'since we'll be changing directory IF INSTR(thecommand$, "/file") = 0 THEN STDOUT "Warning: No /file macro; commands will be generically issued." STDOUT END IF STDOUT "Building directory list..."; STDOUT "Generating file list..."; SHELL "cmd /c dir " & filemask$ & " /s > rwrap.tmp" DIM filelist$(1 TO 50000), dirlist$(1 TO 50000) numfiles = 0 currentdir$ = "" OPEN "rwrap.tmp" 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 IF numfiles >= 50000 THEN STDOUT "(reached max buffer)..."; EXIT LOOP END IF filelist$(numfiles) = MID$(x$, 40) dirlist$(numfiles) = currentdir$ END IF END IF LOOP CLOSE #1 KILL "rwrap.tmp" IF numfiles = 0 THEN STDOUT STDOUT "Error: No files matching " & filemask$ & " could be found. STDOUT EXIT FUNCTION END IF STDOUT "ok" STDOUT "Issuing commands" STDOUT FOR r = 1 TO numfiles STDOUT "cd " & dirlist$(r) CHDIR dirlist$(r) thiscommand$ = thecommand$ REPLACE "/file" WITH filelist$(r) IN thiscommand$ STDOUT thiscommand$ IF nowait = 0 THEN SHELL "cmd /c " & thiscommand$ ELSE x = SHELL("cmd /c " & thiscommand$) END IF NEXT r STDOUT "cd " & goback$ CHDIR goback$ STDOUT STDOUT "rWrap complete; " & FORMAT$(numfiles, ",") & " command(s) issued" STDOUT END FUNCTION