0

I need to make the id in second line to increment by 1.

For example :

user id = 12000

I need second line id number to be 12001, third line id to be 12002, like this up to 60 lines.

Any help?

the code

SET /P _id= Please enter id:
set /P _name= Please enter output name:
streamlink --hls-segment-threads 10 "http://x.x.x.x:xxxx/video/master.m3u8?channelId=%_id%" 720p -l debug -o "%_name%_1.mkv"
streamlink --hls-segment-threads 10 "http://x.x.x.x:xxxx/video/master.m3u8?channelId=%_id%" 720p -l debug -o "%_name%_2.mkv"
streamlink --hls-segment-threads 10 "http://x.x.x.x:xxxx/video/master.m3u8?channelId=%_id%" 720p -l debug -o "%_name%_3.mkv"
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • `first line`, `second line`, and `third line`, are not valid commands, we require a [mcve], along with debugging information explaining what is happening with the code, which is not expected. Currently it appears as if you've not made any attempt at the task, and therefore your question is an off topic code request. Please open a Command Prompt window, type `set /?`, press the `[ENTER]` key, and read through its usage information. Write your own code then [edit] your question such that it meets the requirements set out throughout the pages of [ask]. Thank you. – Compo Oct 12 '21 at 13:24
  • i know that i just mention the line number in additional – Mohamed Serag Oct 12 '21 at 13:29
  • I have removed the invalid strings from your provided code. – Compo Oct 12 '21 at 13:48

1 Answers1

2

There are two different counters. You can manage one with a for /L loop and the other one by incrementing a variable inside the loop:

@echo off
setlocal EnableDelayedExpansion
set /p _id= Please enter id:
set /p _name= Please enter output name:
set /a _id_end=_id+60
set line=0
for /l %%i in (%_id%,1,%_id_end%) do (
  set /a line+=1
  echo streamlink ... "... channelId=%%i" 720p ... -o "%_name%_!line!.mkv"
)
Stephan
  • 53,940
  • 10
  • 58
  • 91
  • its works good but in the output file from line 2 its the same of line 3 and ask to overwrite it File asrar_!line!.mkv already exists! Overwrite it? [y/N] " this is the line 3 output need to overwrite the output of line 2 – Mohamed Serag Oct 12 '21 at 13:42
  • @MohamedSerag the code provided works for me. – Squashman Oct 12 '21 at 13:58
  • 3
    Your error message literally says `File asrar_!line!.mkv already exists`? You forgot `setlocal enabledelayedexpansion` (or have a typo in this command) – Stephan Oct 12 '21 at 14:04
  • i realy can't understant this its first time ti deal with batch files and setlocal enabledelayedexpansion already written – Mohamed Serag Oct 13 '21 at 07:36
  • @Mohamed: see [here](https://stackoverflow.com/questions/30282784/variables-are-not-behaving-as-expected/30284028#30284028) for an explanation/demonstration of delayed expansion (I tried to keep it short and simple). – Stephan Oct 13 '21 at 09:36