Note that there are some explanatory texts on larger screens.

plurals
  1. POWindows Command line script decrementing variables in FOR loop based on a user defined starting variable
    text
    copied!<p>I'm trying to write what seemed like an easy script but I can't figure it out.</p> <p>Basically, a user is asked Question 1: "How many (in this case) video files they want to add together to create 1 big video file?"</p> <p>The user then gets asked Question 2: "what is the name of the file you want to add together?" Now here is the problem I'm having... </p> <p>How do I create a for loop that asks that Question 2 the amount of times given in the 1st question and saves each answer as a unique variable (I'm guessing at decrementation of the variable)</p> <p>after I have all the correct file names from the user then the program will call the video program according to the video program syntax (THAT syntax I don't need help with, I understand that part)</p> <p>ex. (a "?" means i don't know what to put there)</p> <p>@echo off</p> <p>set /p howmany=How many files do you want to add?</p> <p>for /? %%variable(???) in (%howmany%???) do (set /p inputfilename=what is the name of the first file you want to add? inputfilename=filename set %howmany%-1???=%howmany%????)</p> <p>so if the user answered 5 to the Question 1, then the for loop should ask Question 2 five times and create 5 unique variables for every time the answer is given. inputfilename1 = movie1.mov inputfilename2 = movie2.mov etc..</p> <p>I've been trying to figure this out for a few days.. I can't rap my head around it. I've done plenty of for commands before but this has got me stumped. My browser history is full of google searches that seems like something people would ask about any kind of files. If I did find anything remotely close to this question it was always asked for a different programming language. My brain is fried. Is this even something possible? Please help and thanks in advance.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload