Help with loop increment & variables
Posted: 27 Apr 2013 00:35
EDIT - Removed example/pseudo code. Figured out how to articulate the root of my problem(s).
What I am trying to do is use a loop. I don't quite understand how to loop anything at all. I also don't understand or know how to incrementally change from one sequential file and/or variable to the next. That is my main problem.
Looking at a directory/folder for example what I mean when I say sequential is the files & their order.
I am able to execute everything without incident. When I do so without looping. The reason I want the loop is so that one segment of code can be used. Instead of having to copy/paste/alter everything an indefinite amount of times.
So my questions are:
Can someone please explain how to loop a segment of code? If not direct me somewhere that explains it simply. My searches haven't turned up anything I could understand. Simply seeing code to loop "echo Hello World" a set number of times would suffice.
How does one go from one sequential variable to the next & how is it defined as first, last, etc.. is it possible?
Example if %variable1% is set in %primaryVariable% how would you automatically set it to %variable2%, %variable3%, etc.. & then stop incrementing at the appropriate time?
I was also wondering if there was a way to read through a directory alphanumerically focusing only on a specific file extension. Even without extension specificity if need be. Then set the individual file names as a variable.
Sorry I've not been clear enough. I tried to explain as best I could with pseudo and example code as I wasn't even entirely sure what I needed help with. Hopefully this clears things up. Any & all help is greatly appreciated. I understand you're taking time out of your day to pay my little problem attention. And I thank you all for that.
Also thank you abc0502 for the info on the quotes. I've been doing that wrong for far too long now.
What I am trying to do is use a loop. I don't quite understand how to loop anything at all. I also don't understand or know how to incrementally change from one sequential file and/or variable to the next. That is my main problem.
Looking at a directory/folder for example what I mean when I say sequential is the files & their order.
I am able to execute everything without incident. When I do so without looping. The reason I want the loop is so that one segment of code can be used. Instead of having to copy/paste/alter everything an indefinite amount of times.
So my questions are:
Can someone please explain how to loop a segment of code? If not direct me somewhere that explains it simply. My searches haven't turned up anything I could understand. Simply seeing code to loop "echo Hello World" a set number of times would suffice.
How does one go from one sequential variable to the next & how is it defined as first, last, etc.. is it possible?
Example if %variable1% is set in %primaryVariable% how would you automatically set it to %variable2%, %variable3%, etc.. & then stop incrementing at the appropriate time?
I was also wondering if there was a way to read through a directory alphanumerically focusing only on a specific file extension. Even without extension specificity if need be. Then set the individual file names as a variable.
Sorry I've not been clear enough. I tried to explain as best I could with pseudo and example code as I wasn't even entirely sure what I needed help with. Hopefully this clears things up. Any & all help is greatly appreciated. I understand you're taking time out of your day to pay my little problem attention. And I thank you all for that.
Also thank you abc0502 for the info on the quotes. I've been doing that wrong for far too long now.