How to Copy (and increment) Multiple Instances of a File Using Batch File

You can try like this :

@echo off
set Source=C:\TEMP\MyDoc.txt
set Destination=E:\MyData\
set Filename=MyDoc
set a=1

:loop
if exist %Destination%\%Filename%(%a%).txt set /a a+=1 && goto :loop
copy %Source% %Destination%\%Filename%(%a%).txt
pause

Leave a Comment