views:

46

answers:

2

I have a file called header.txt I want this file to be prepended (first line) to all *.txt files in the same directory.

How could I achieve this?

Thanks in advance, Joe

+1  A: 

use for loop, and then copy + command.

See copy /? for copy + syntax.

See for /? for for syntax.

Pavel Radzivilovsky
+4  A: 
@echo off
for %%x in (*.txt) do call :merge %%x
goto :eof

:merge
copy header.asc + %1 %1.new
del %1
ren %1.new %1
exit /b

Don't call the file header.txt though, because you don't want to prepend the header to itself (that's why I called it header.asc).

Make a backup before trying ;)

Michael
Thanks for the answer.
jmituzas