why is the variable "number" not increasing when the FOR loop goes over it again?
setLocal EnableDelayedExpansion
for /f "tokens=* delims= " %%a in (input.txt) do (
set /a N+=1
set /a number=!number!+1
echo %%a !number!.jpg >output.txt
)
why is the variable "number" not increasing when the FOR loop goes over it again?
setLocal EnableDelayedExpansion
for /f "tokens=* delims= " %%a in (input.txt) do (
set /a N+=1
set /a number=!number!+1
echo %%a !number!.jpg >output.txt
)
OK, try this please:
@echo off &setLocal EnableDelayedExpansion
(for /f "tokens=* delims= " %%a in (input.txt) do (
set /a N+=1
set /a number=!number!+1
echo %%a !number!.jpg
))>output.txt
In case of redirection you need >>output.txt
or a code block (parentheses) and >output.txt
.
First of all I don't recommend you to enable expansion of variables when you are working with filenames, use it only if you really know what means enabling the delayedexpansion, the benefits (improved velocity) and the negatives (missing characters).
Also you are assigning a value for the variable "N" but you don't use that var.
Here is the code:
@echo off
(for /f "usebackq tokens=* delims= " %%a in ("input.txt") do (
Set /A Number+=1
Call Echo %%a %%number%%.jpg
))>"Output.txt"
Pause&Exit
You should try
setLocal EnableDelayedExpansion
for /f "tokens=* delims= " %%a in (input.txt) do (
set /a N++
set /a number=!number!+1
echo %%a !number!.jpg >output.txt
)
EDIT
Or try:
setLocal EnableDelayedExpansion
for /f "tokens=* delims= " %%a in (input.txt) do (
set /a N++
set /a number=!number!++
echo %%a !number!.jpg >output.txt
)
Or maybe that ++ isnt even supported by what you are using to program this. Let me know though!
Shadowpat