batch how to assign a number to a string

December 7, 2010 at 06:01:37
Specs: Windows Vista
Hello there,
my problem: I want to assign recursively the numbers of a counter to a string inside a for loop

setLocal EnableDelayedExpansion
set count = 0
for %f in (*.*) do (
set /a count+=1
echo "(0020,0013)=%count%" ????
)

EndLocal

I want this:
first run: "(0020,0013)=1"
second run: "(0020,0013)=2"
...and so on

thanks


See More: batch how to assign a number to a string

Report •

#1
December 16, 2010 at 12:07:49
Your code works fine if you use of "!" instead of "%" in the echo and if you add a second "%" in the for.

@echo off
setLocal EnableDelayedExpansion
set count = 0
for %%f in (*.*) do (
set /a count+=1
echo "(0020,0013)=!count!"
)
endlocal

Check the code and let me know if it is what you needed.


Report •

#2
December 17, 2010 at 11:30:16
Thanks a lot David,
now it works correctly.

best regards,
Luca


Report •
Related Solutions


Ask Question