To do what you need you can use for / l . With this command you can iterate between an initial number and a final number, with the increment you need. With the result of the for, just apply "0" to the left to get the format you want. It would stay like this
@echo off
title Crear Nombres a partir de un solo nombre
REM color 56
cls
echo Cual es el numero maximo de este Patch? (cantidades entre 1 y 9999)
set /p numero=
SETLOCAL EnableDelayedExpansion
FOR /L %%g IN (1,1,%numero%) DO (
set relleno=0000%%g
echo copy plantilla.patch ps!relleno:~-4!.patch
)
Execution example:
Cual es el numero maximo de este Patch? (cantidades entre 1 y 9999)
10
copy plantilla.patch ps0001.patch
copy plantilla.patch ps0002.patch
copy plantilla.patch ps0003.patch
copy plantilla.patch ps0004.patch
copy plantilla.patch ps0005.patch
copy plantilla.patch ps0006.patch
copy plantilla.patch ps0007.patch
copy plantilla.patch ps0008.patch
copy plantilla.patch ps0009.patch
copy plantilla.patch ps0010.patch
There is a change in the line of set /p
, you have to remove the %
and the space. Assuming you have a template.patch file, the best option is to make a copy, in order to generate copies of your template with the desired names. In your script remove echo
to make the copy, I have put it to see the result;).