Change Automatic Names

0

Good day I have this Scrip that I would like to modify and that when I double-click it I create ps9999.patch from number 1 without being typing numbers one by one is there any way?

@echo off
title Crear Nombres a partir de un solo nombre
color 56
cls
echo Cual es el numero maximo de este Patch? (cantidades entre 1 y 9999)
set /p %numero% = 
REN ps0001.patch ps%numero%.patch

I want to do something like when you copy a file in the same directory and create a number to differentiate the first file from the last copy but it starts from ps0001.patch and ends in ps9999.patch always keeping 4 numeric digits

    
asked by Juan Carlos Villamizar Alvarez 08.07.2018 в 15:15
source

1 answer

0

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;).

    
answered by 13.07.2018 в 13:15