FOR %%F in (*.foo) DO command %%F
Operates the command command
on with each filename as the first argument.
Remember that when in a batch file you must use %%
where on the command line, the above would only use single %
's.
If you need the full pathname, or to get files recursively, use the /R
switch of the for command.
Example:
C:\WINDOWS> FOR %F in (*.exe) DO @echo %F
explorer.exe
FramePkg.exe
gsk7bui.exe
hh.exe
IsUninst.exe
NOTEPAD.EXE
notepad1.exe
regedit.exe
slrundll.exe
TASKMAN.EXE
twunk_16.exe
twunk_32.exe
uninst.exe
winhelp.exe
winhlp32.exe
C:\WINDOWS> FOR /R %F in (*.exe) DO @echo %F
C:\WINDOWS\explorer.exe
C:\WINDOWS\FramePkg.exe
C:\WINDOWS\gsk7bui.exe
C:\WINDOWS\hh.exe
C:\WINDOWS\IsUninst.exe
C:\WINDOWS\NOTEPAD.EXE
C:\WINDOWS\notepad1.exe
C:\WINDOWS\regedit.exe
C:\WINDOWS\slrundll.exe
C:\WINDOWS\TASKMAN.EXE
C:\WINDOWS\twunk_16.exe
C:\WINDOWS\twunk_32.exe
C:\WINDOWS\uninst.exe
C:\WINDOWS\winhelp.exe
C:\WINDOWS\winhlp32.exe
... [lots more] ...
C:\WINDOWS\system32\accwiz.exe
C:\WINDOWS\system32\actmovie.exe
C:\WINDOWS\system32\ahui.exe
C:\WINDOWS\system32\alg.exe
C:\WINDOWS\system32\append.exe
C:\WINDOWS\system32\arp.exe
C:\WINDOWS\system32\asr_fmt.exe
C:\WINDOWS\system32\asr_ldm.exe
... [etc..]
C:\WINDOWS\system32\dllcache\accwiz.exe
C:\WINDOWS\system32\dllcache\actmovie.exe
C:\WINDOWS\system32\dllcache\admin.exe
C:\WINDOWS\system32\dllcache\agentsvr.exe
C:\WINDOWS\system32\dllcache\ahui.exe
C:\WINDOWS\system32\dllcache\alg.exe
C:\WINDOWS\system32\dllcache\append.exe
C:\WINDOWS\system32\dllcache\arp.exe
... [and so forth..]