Posted By

pollusb on 05/13/11


Versions (?)

How to use 2 FOR loop in a batch dos command

 / Published in: DOS Batch

This code will simply add the filename in front of each line for all files that match *.txt. This way, you can combine a large number of CSV files into 1 file by using a pipe redirect.

  1. @echo off
  2. FOR /F "tokens=*" %%F in ('dir *.txt /b') do FOR /F "tokens=*" %%L in (%%F) do echo %%F,%%L >> CombinedFile.txt

Report this snippet  

You need to login to post a comment.