How to increment a value in a txt file in BATCH.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • TJIZIL
    New Member
    • Jan 2014
    • 2

    How to increment a value in a txt file in BATCH.

    Dear Bytes Community,

    First of all I would like to thank you in advance for helping me.

    I have been trying to write a batch code that will:

    1. Auto execute after POST.
    2. Increment a value that is suppose to represent number of the POSTs.
    3. Save, display the value and restart the PC.

    I have tried to write one that access a txt file for the value; however the value does not increment.

    Code:
     
     
    @echo off
     
    echo.This script is counting the # of POSTs.
     
    cd "C:\Users\HP-M6\Documents"
    for /f "tokens=* delims=" %%x in (TEST.txt)  do echo %%x
     
    call:myPOSTTest
     
    for /f "tokens=* delims=" %%x in (TEST.txt)  do echo %%x
     
     
    echo.&pause&goto:eof
     
     
    ::--------------------------------------------------------
    ::-- Function section starts below here
    ::--------------------------------------------------------
    -- 
    :myPOSTTest    - here starts my function identified by it's label
     
     
    cd "C:\Users\HP-M6\Documents"
     
    for /f "tokens=* delims=" %%x in (TEST.txt) do (
     
    set %x%+=1
     
    )
     
     
    goto:eof
  • ryno du preez
    New Member
    • Jul 2011
    • 91

    #2
    We need more info
    What must auto execute? after posting What?
    Do you want the batch to write to a text file and auto increment a colum like 1 2 3 ect.

    Comment

    Working...