Home > database >  what are the limits to a counter in batch
what are the limits to a counter in batch

Time:08-14

I'm working on a script and I am adding a counter to it, but I'm not sure how to control it better

I added this to my script - My script is very large about 96 rows so I am trying to only focus on building counters

Set A/ Serial=0
and then this
Set A/ serial =1

When I run my tester.txt it counts like it's suppose to like this

New folder 1\tester.txt before - current script
this is the content inside my tester.txt
    "code" 0
    "code" 0
    "code" 0
    "code" 0
    "code" 0
    "code" 0
    "code" 0
    "code" 0
    "code" 0
    "code" 0
    "code" 0
    "code" 0

I want to reach 2 results

New folder 2\tester.txt results  ----- current script results
this is the content inside my tester.txt
    "code" 0
    "code" 1
    "code" 2
    "code" 3
    "code" 4
    "code" 5
    "code" 6
    "code" 7
    "code" 8
    "code" 9
    "code" 10
    "code" 11

what I am trying to do is this

RESULTS 1

New folder 2\tester.txt results  ----- My goal
this is the content inside my tester.txt
    "code" 0
    "code" 1
    "code" 2
    "code" 3
    "code" 4
    "code" 5
    "code" 0
    "code" 1
    "code" 2
    "code" 3
    "code" 4
    "code" 5

I'm hoping just to understand how to control it better, because my next question for a counter is trying to make it do this

RESULTS 2

tester.txt aiming results ----- My goal
this is the content inside my tester.txt
        "part" 1
        "part" 1
        "part" 1
        "part" 1
        "part" 1
        "part" 1
        "part" 2
        "part" 2
        "part" 2
        "part" 2
        "part" 2
        "part" 2
        "part" 3
        "part" 3
        "part" 3
        "part" 3
        "part" 3
        "part" 3

my tester.txt will literally have the same code repeated from 6 to 18 times

@ECHO Off
setlocal ENABLEDELAYEDEXPANSION
cd /d "%~dp0"

set "replacemain3="name": ""
set "replacemain4="code": "
set "replacemain5="part": "

@For %%G In ("%~dp02Preparing") Do Set "sourcedir=%%~fG"
@For %%G In ("%~dp03Ready") Do Set "destdir=%%~fG"

SET /a serial1=0
SET /a serial2=1

FOR /f "delims=" %%q IN ('dir /b /s /a-d "%sourcedir%\*.txt"') DO (
 rem calculate new destination directory
 SET "newdest=%%~dpq"
 SET "newdest=!newdest:%sourcedir%=           
  • Related