Windows batch file with TYPE command

batchcommand linewindows

I have 10 files like below:

  • file1.txt (file content = "i contain text for file1")
  • file2.txt (file content = "i contain text for file2")
  • file3.txt (file content = "i contain text for file3")

and so


I am trying to do a TYPE command like:

type file*.txt > OUTPUT.txt

this works to output the file contents only. i need output to also have filename for each file.

my output.txt file should look like this:

file1.txt = "i contain text for file1"
file2.txt = "i contain text for file2"
file3.txt = "i contain text for file3"

Best Answer

Create a batch file called proc.bat which contains:

echo %1=>>output.txt
type %1>>output.txt

Then use this command:

for %v in (file*.txt) do proc %v
Related Question