Walk a directory/Recursively: Difference between revisions

m
→‎{{header|REXX}}: reinstated original program; changed/added comments, added an example output.
m (→‎{{header|REXX}}: elided redundant REXX word in the REXX version titles for REXX.)
m (→‎{{header|REXX}}: reinstated original program; changed/added comments, added an example output.)
Line 1,601:
{{works with|Regina}}
The following program was tested in a DOS window under Windows/XP and should work for all Microsoft Windows.
<lang rexx>/*REXX program shows all files in a single directory tree that match a given search criteria.*/
parse arg xdir; if xdir='' then xdir='\' /*Any DIR specified? Use Then use default.*/
@.=0 /*default result in case ADDRESS fails. */
tracedirCmd= off'DIR /b /s' /*suppressthe DOS command REXXto errdo msgheavy forlifting. fails*/
iftrace off rc\==0 then do /*ansuppress REXX error happened?message for fails*/
address system 'DIR' dirCmd xdir '/b' with output stem @. /*issue the DOS DIR cmd.command with option*/
if rc\==0 then do /*an error happened?*/
if rc\==0 then do say '***error!*** from DIR' xDIR /*indicatedid quethe pasa.DOS DIR command get an error?*/
say 'return***error!*** from code=DIR' xDIR rc/*error message that shows "que pasa". /*show the Ret Code.*/
exitsay rc'return code=' rc /*show the return code from DOS /*exit with the RCDIR.*/
endexit rc /*exit with " " " " /* [↑] " bad address.*/
#=@.rc end /*number of[↑] entries. bad ADDRESS cmd (from DOS DIR)*/
if #==0@.rc then #=' no ' /*usethe number of @. a word,entries ¬zerogenerated.*/
if #==0 then #=' no ' /*use a better word choice for 0 (zero)*/
say center('directory ' xdir " has " # ' matching entries.', 79,' "'")
 
do j=1 for #; say @.j; end /*show all the files that met criteria. */
end /*j*/
 
exit @.0+rc /*stick a fork in it, we're all done. */</lang>
'''output''' &nbsp; when the following was used: &nbsp; <tt> I:\firefox*.exe </tt>
<pre>
─────────────directory I:\firefox*.exe has 6 matching entries.─────────────
I:\FIREFOX\firefox.exe
I:\FIREFOX\INSTALL\Firefox Setup 1.5.0.1.exe
I:\FIREFOX\INSTALL\Firefox Setup 2.0.0.4.exe
I:\FIREFOX\INSTALL\Firefox Setup 3.0.4.exe
I:\FIREFOX\INSTALL\Firefox Setup 3.6 Beta 5.exe
I:\FIREFOX\INSTALL\Firefox Setup 4.0 Beta 11.exe
</pre>
 
===version 2===