Walk a directory/Recursively: Difference between revisions
Content added Content deleted
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: | Line 1,601: | ||
{{works with|Regina}} |
{{works with|Regina}} |
||
The following program was tested in a DOS window under Windows/XP and should work for all Microsoft Windows. |
The following program was tested in a DOS window under Windows/XP and should work for all Microsoft Windows. |
||
<lang rexx>/*REXX program shows files in a |
<lang rexx>/*REXX program shows all files in a directory tree that match a given search criteria.*/ |
||
parse arg xdir; if xdir='' then xdir='\' |
parse arg xdir; if xdir='' then xdir='\' /*Any DIR specified? Then use default.*/ |
||
@.=0 /*default in case ADDRESS fails. |
@.=0 /*default result in case ADDRESS fails.*/ |
||
dirCmd= 'DIR /b /s' /*the DOS command to do heavy lifting. */ |
|||
⚫ | |||
address system |
address system dirCmd xdir with output stem @. /*issue the DOS DIR command with option*/ |
||
⚫ | |||
if rc\==0 then do /*did the DOS DIR command get an error?*/ |
|||
say ' |
say '***error!*** from DIR' xDIR /*error message that shows "que pasa". */ |
||
say 'return code=' rc /*show the return code from DOS DIR.*/ |
|||
exit rc /*exit with " " " " " */ |
|||
end /* [↑] bad ADDRESS cmd (from DOS DIR)*/ |
|||
#=@.rc /*the number of @. entries generated.*/ |
|||
if #==0 then #=' no ' /*use a better word choice for 0 (zero)*/ |
|||
say center('directory ' xdir " has " # ' matching entries.',79, |
say center('directory ' xdir " has " # ' matching entries.', 79, "─") |
||
do j=1 for #; say @.j |
do j=1 for #; say @.j /*show all the files that met criteria.*/ |
||
end /*j*/ |
|||
exit @.0+rc /*stick a fork in it, we're done.*/</lang> |
exit @.0+rc /*stick a fork in it, we're all done. */</lang> |
||
'''output''' when the following was used: <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=== |
===version 2=== |