How to use 2 FOR loop in a batch dos command

/ Published in: DOS Batch
Save to your folder(s)

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.

Copy this code and paste it in your HTML
  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


RSS Icon Subscribe to comments

You need to login to post a comment.