Hi,
I am trying to write a batch script were i will prompt for a 'X' and 'Y' value. I then need to generate files from a single file.
I need to have something like this:-
filename_X01_Y01.xxx
filename_X01_Y02.xxx
filename_X01_Y03.xxx
filename_X01_Y04.xxx
filename_X02_Y01.xxx
filename_X02_Y02.xxx
filename_X02_Y03.xxx
filename_X02_Y04.xxx
The idea is that i need to create all files with all variations of X and Y so if you have value X = 20 and value Y = 20 this would generate 420 files.
At the moment I am generating the names in excel and then pasting them into the batch file. This would then add 420 commands and would be static in the number of files. I would like to have the option to generate a variable amount based on X and Y value.
Any help would be appreciated.
Creating filenames automatically with X and Y
Moderator: DosItHelp
Re: Creating filenames automatically with X and Y
Code: Select all
@echo off
setlocal EnableDelayedExpansion
rem Read last values
set /P "lastX=X = "
set /P "lastY=Y = "
rem Generate the desired names
set /A X=100
for /L %%X in (1,1,%lastX%) do (
set /A X+=1, Y=100
for /L %%Y in (1,1,%lastY%) do (
set /A Y+=1
echo filename_X!X:~1!_Y!Y:~1!.xxx
)
)
Re: Creating filenames automatically with X and Y
Thank you for your help, great and simple file generation process. Just could not get my head around the process.