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
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
use for loop, and then copy + command.
See copy /? for copy +
syntax.
See for /? for for syntax.
@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 ;)