Thursday, March 26, 2009

How to Expand Windows Filename Globs in a Batch File

This one I needed dearly today:

In windows, filename globs like *.xml do not get expanded by the shell. Its up to each script and program to do it. Thanks for nothin' MSFT!

Here is how to do it in a batch file - a simple example, which does the equivalent of a dir command:

@echo OFF
for %%f in (%1) do (
echo %%f

Happy coding.

No comments: