1.

Solve : Save?

Answer»

Hey

Well my problem is that I need a batch file to copy a number or numbers into a file and read off it next time it's loaded.

so like


set /a ex=5
...
...
set /a ex=%ex% +1
echo %ex%>file.txt

and have it set ex to 6 next time it is run, instead of 5Let's see what efforts you've made?
Well I tryed
echo file.txt>%0

but that just deleted EVERYTHING and COPIED file.txt into the batch file.Quote from: supabunny on February 23, 2008, 05:28:52 PM

echo file.txt>%0
I think I see what you were trying to do, but you had your redirection the wrong way.
> is to OUTPUT TO a file
< is to read FROM a file

Look up the syntax on the SET COMMAND. Specifically SET /P. There are even some examples on this forum on using SET /P in a batch file to set a variable from a file.ok well I tryed
Code: [Select]@echo off
set /a ex=0
set /a ex=%ex% + 1
echo %ex%
pause>nul
echo %ex%>file.txt

set /p ex2=file.txt<%0
echo %ex2%
pause>nul
and it ended up with
1

[emailprotected] off


I think this is because it's copying
ECHO is off.
into the file.txt

im not sure about the [emailprotected] off thing


Discussion

No Comment Found