0

I have a text file Foo.txt which contains value content0. I have to create a batch file which increment the text file like Foo1.txt, Foo2.txt.....Foo5.txt and also the values in the file content1, content2,...content5. The Foo1.txt should have the value content1

I have written the code to increment the file the following way:

@echo off

for /L %%i IN (1,1,5) do call :docopy %%i
goto end

:docopy
set FN=%1
set FN=%FN:~-3%

copy C:\Users\sindhu\Desktop\foo.txt foo%FN%.txt

:end

But I don't want to write the code to increment the value inside the file. Please help me on this.

1 Answer 1

1

Try this

@echo off

for /L %%i IN (1,1,5) do copy /y NUL C:\temp\foo%%i.txt >NUL & echo content%%i > C:\temp\foo%%i.txt

Not the answer you're looking for? Browse other questions tagged .