/* FORD, Version 2.04 */ /* Partial FOR /D (NT) "port" */ /* Written by Rob van der Woude */ parse arg "#" -1 var +2 in "(" filespec ")" do commandline do = translate( strip( do ) ) in = translate( strip( in ) ) if var = "%%" then call Syntax if do <> "DO" then call Syntax if in <> "IN" then call Syntax if commandline = "" then call Syntax if filespec = "" then call Syntax call SysFileTree filespec, "dir.", "DO" if dir.0 < 1 then call DirNotFound parse value commandline with commandstr paramstr if paramstr <> "" & dir.0 > 0 then do if pos( var, paramstr ) > 0 then call ParseParamStr end ford_confirm = translate( value( "FORD_CONFIRM", , "OS2ENVIRONMENT" ) ) if dir.0 > 0 & ford_confirm <> "NO" then do i = 1 to dir.0 say right( i, 5, " " )||" "||commandstr||" "||paramstr.i end if ford_confirm <> "NO" then do say say "Are you sure you want to execute these commands?" call SysCurState "OFF" answer = translate( SysGetKey( "NOECHO" ) ) if answer <> "Y" then EXIT 2 end do i = 1 to dir.0 address CMD commandstr||" "||paramstr.i end EXIT 0 DirNotFound: say say "Specified directories not found: "||filespec call Syntax return ParseParamStr: procedure expose dir. paramstr paramstr. var do i = 1 to dir.0 paramstr.i = paramstr do forever varpos = pos( var, paramstr.i ) if varpos = 0 then leave leadstr = substr( paramstr.i, 1, varpos - 1 ) trailstr = substr( paramstr.i, varpos +2 ) paramstr.i = leadstr||dir.i||trailstr end end return Syntax: say say "FORD, Version 2.04" say "Partial port of Windows NT's FOR /D command" say say "Usage: FORD #v IN (filespec) DO command parameters" say say "#v v may be any character, except %" say "filespec Directory specification (with wildcards)" say "command any valid OS/2 command" say "parameters command's command line parameters; any occurrance of" say " #v in the parameters string will be replaced with a" say " directory from filespec" say say "If the environment variable FORD_CONFIRM is set to NO," say "the program will NOT ask for confirmation." say say "Written by Rob van der Woude" say "http://www.robvanderwoude.com" EXIT 1 return