Duplicate and rename by increment of 1


I have a file 00185.txt, how do I create a batch file to duplicate this file and rename to 00186.txt, then continue to duplicate another 150 times by an increment of one.

eg. original file is 00185.txt, duplicate this and rename to 00186.txt, then the next would be 00187.txt, all the way to 00300.txt.

Any help would be greatly appreciated. Thank you.


@echo off

if not exist "00185.txt" echo Stack overflow example > "00185.txt"

set first=186
set /A last=%first% + 150
for /L %%A IN (%first%,1,%last%) do @copy /B /Y "00185.txt" "00%%A.txt" > nul

Answered By – Anders

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published