|
Answer» Hi, Is there a batch command that checks the value in the file test.txt? After that, it will increment the value by 1.
Its KIND of a counter that will be used for me to save the state other batch file.
Thnaks! Lekfir you mean how many rows are in this file ??
if so :
Code: [Select]setlocal enabledelayedexpansion for /f %%a in (file.txt) do ( set /a num+=1 ) echo %num% Thanks for your replay!
But I still dont have the answer. Let me explain Lets say that I have 2 files: File.txt that contains only the value 1 in it. Test.bat file that has 2 goals: 1. Checks the value in the file.txt and if it is > 4 it will Call to another batch file. 2. After the check, it will increment the value in the file.txt by 1 each time I call to Test.bat.
Thanks! my Hero.As long as there is but a single value in file.txt, you can eliminate that pesky delayed expansion:
Code: [Select]set /p num=<file.txt if %num% GTR 4 call another set /a num=%num%+1 echo %num% > file.txt
Sidewinder Thank you very much! It WORKED great.
BTW, Can I place the file.txt in a different location. not in the same location with the Test.bat? For example: Test.bat is located in d:\ and file.txt in c:\ ? Like here:
set /p num=if %num% GTR 4 call another set /a num=%num%+1 echo %num% > c:\file.txt
Quote Can I place the file.txt in a different location. not in the same location with the Test.bat
This is the type of question you could answer by TRYING the code. In fact the answer is yes. You can never go wrong using the PATH of a file, provided of course the path is correct. Thanks!
|