开发者

.bat Merging header.txt to all *.txt files

I have a file called header.txt I wa开发者_StackOverflow社区nt this file to be prepended (first line) to all *.txt files in the same directory.

How could I achieve this?

Thanks in advance, Joe


@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 ;)


use for loop, and then copy + command.

See copy /? for copy + syntax.

See for /? for for syntax.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜