0

This batch line works with full filenames:

for /f "skip=3 delims=*" %%g in (cc_data_3-3-2016_15-37-19.xml  cc_data_3-28-2016_0-25-36.xml) do (echo %%g >>tempfile.txt)

This one doesn't when filenames are replaced by a wildcard:

for /f "skip=3 delims=*" %%g in (*.xml) do (echo %%g >>tempfile.txt)

What's wrong and what should I do to make it work? I need the *.xml files. They are in the same folder as the batch file.

0

1 Answer 1

2

for /f takes a filename only. If you want to use a wildcard, you'll need to expand the wildcards yourself. You can use for to do that, just not in one call:

for %%f in (*.xml) do (
    for /f "skip=3 delims=*" %%g in (%%f) do (echo %%g >>tempfile.txt)
)
Sign up to request clarification or add additional context in comments.

4 Comments

@Anon_C What a wonderful solution! It works like a charm. Thank you so much. Where can I find some documentation about this arcane feature?
Instead of echo %%g >>tempfile.txt I would write >> tempfile.txt echo %%g in order to avoid a trailing space to be echoed too...
@AnonCoward Then why for %%f in (*.xml) without parameter /f can dosomething?
Because that does take a wildcard and returns filenames from the filesystem.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.