Saved Bookmarks
| 1. |
Solve : Counting in batch file?? |
|
Answer» HI, i would like to create a batch file thats says how MANY time(s) you already opened it. example: if you open it for the first time it must say: you opened it 1 time(s). If you open it for the SECOND time it must say: you opened it 2 time(s) . If you open it four the thousand time it must say: you opened it 1000 time(s). [glb]Can somebody help me[/glb] please, i tried so long, but i just can't find how to do it. P.S. excuse me for my bad very bad english, i'm from Holland You would need an external file to keep a counter. Each time the batch file RUNS, you would read the file, increment the counter, write the new value to the file, and return the counter value to the user. If you have a 2000 or XP machine, you could use the FOR command to read the file, the SET command to increment the counter, and the ECHO command to update the file and return the value to the user. If you have a Win9x machine, the SET command does not have the functionality to do arithmetic. Good luck. how do you have to set that it have to count each time +1 i can do something like that: @echo off if exist %temp%/firstime.txt goto exist echo this is you first time >> %temp%/firstime.txt ECHO first time goto end :exist this is not your first time goto end :end pause that's for looking under windows xp if its the first time or not, but i would like that my program looks more than just the first time, so it olso can look if it is the hundertst time Here a little code to count lines in a textfile: (It works with NT4 so it should also do it in XP also.) *************** set log=c:\test.txt set sitem=opened echo opened >>%log% For /F "tokens=3 delims=:" %%A in ('Find /c "%sitem%" %log%') Do Set RN=%%A echo %RN% set source= set RN= set log= set sitem= ***************** Hope this helps uliThis script works , THANK you very much greetz, black berry |
|