I am trying to create a batch script for my Windows machine that loops through a list of (string/decimal) values and uses each value as a parameter inside the loop.
Below is an example of a simple for loop I would like to use to display all the different version files (from my list)
FOR ? in ('1.1','1.2','2.4','3.9') do echo V[value_from_for_loop].txt
I am having trouble in how to loop through each item and use a variable in my echo statement.
set input="path/to/file. txt" for /f "tokens=* delims=[" %i in ('type "%input%" ^| find /v /n ""') do ( set a=%i set a=!a:*]=]! echo:!a:~1!) Works with leading whitespace, blank lines, whitespace lines.
Example# @echo off prevents the prompt and contents of the batch file from being displayed, so that only the output is visible. The @ makes the output of the echo off command hidden as well.
FOR /D - Loop through several folders. FOR /L - Loop through a range of numbers. FOR /F - Loop through items in a text file. FOR /F - Loop through the output of a command.
for %x in (1.1 1.2 2.4 3.9) do echo V%x.txt
For use in a batch file you'll have to double the %
:
for %%x in (1.1 1.2 2.4 3.9) do echo V%%x.txt
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With