PillarSoft

http://www.pillarsoft.net/os-2-software/rexx/read-directory-into-queue-analyze-file-names-run-p.shtml

Read directory into queue, analyze file names, run process (Beginning and Intermediate level)

Contributed by: Doug Rickman, Global Hydrology and Climate Center, MSFC, NASA

This is aimed at beginning and intermediate REXX users.


 


/*****************************************************************************/
/**************************** Queue Control2 *********************************/
/* Using a queue obtain a directory list, select files based on some criteria*/
/* and then do an external command/program.                                  */

/* Create a named queue, make it active,flush it, then fill it with the      */
/* directory list.                                                           */
rc=rxqueue('CREATE','DIRLISTQ')
rc=rxqueue('SET','DIRLISTQ')
do while queued()<>0
   pull afile
   end
'@echo off'
'dir /f | rxqueue 'DIRLISTQ        /* NOTE USE OF FILTER */

/* Define the default directories */
BinDirectory=VALUE('ELASII',,'OS2ENVIRONMENT')||'\bin\'

do while queued()<>0
   parse pull afile
   say 'Checking 'afile
   parse value parsefn(afile) with drive path filename extension
   /* Find file names with extensions = a string of numbers. */
   if datatype(extension,'W') then do
      Output=drive':'path||filename'_'extension'.'log
      /* Does an output file already exist, if so skip this file. */
      if dosisfile(Output) then nop
      else do
         say 'Running decode_atlas for' afile
         BinDirectory||'decode_atlas.exe 'afile ' > 'output
         end
      end /* if datatype(extension,'W') then ...  */
   end /* do while queued()<>0  */
return