Reputation: 391
The titles says everything, I have a txt file called totalcred.txt
with a number, all I want to do is:
.txt
file in a variableBut nothing on this earth worked until now, I got dissapointed.
Here's my code so for (I tried lot of things too):
FOR /F "tokens=1" %%a IN (totalcred.txt) DO (
set val=%%a
IF [%val%] GEQ [0] (
set /a val += 195
echo %val% > totalcred.txt
)
)
Upvotes: 1
Views: 757
Reputation: 391
FOR /F "tokens=1 delims=" %%a IN (totalcred.txt) DO (
set /a val=%%a+0
goto con
)
:con
set /a val2=%val%+100
echo %val2%
(Echo(%val2%)>totalcred.txt
Upvotes: 0
Reputation: 38589
You don't even need a for
loop, which as you can imagine is problematic when trying to read from the same file you're writing to:
@Echo Off
Set/P "val="<totalcred.txt
If %val% GEq 30000 GoTo :EOF
Set/A "val+=195"
(Echo(%val%)>totalcred.txt
Upvotes: 1