Reputation: 1
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
@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 to write the code to increment the value inside the file. Please help me on this
Upvotes: 0
Views: 252
Reputation: 5281
Adding to stephan's answer,
First read the content of foo.txt
into the variable content
like so:
set /p content=<foo.txt
Then the final code will look like:
set /p content=<foo.txt
for /L %%i IN (1,1,5) do echo %content%%%i>foo%%i.txt
here %content%
is replaced by the actual content that was read from foo.txt
in all the files foo%%i
.
Upvotes: 1
Reputation: 56180
when I understand you question correct:
for /L %%i IN (1,1,5) do echo content%%i>foo%%i.txt
Upvotes: 1