batch-filecmdcommand-linewindows-11

Is there a way to open a batch file at a certain line using a command prompt window


Im testing a batch file that Im still in the process of making and I want to open it at line 6 instead of line 1 since ive already run that part of the code. it takes a couple of minutes to run it since im using ffmpeg.

this is the first area of the code

@Echo off
set /p IPath=Enter the Path of the file you wish to remux from (use "Copy as path" option and keep  the Quotations): 
set /P M=what is the first letter of the path of your new file?(do not include the semicolon(:))
set /p NewPath=Enter the Path you wish to remux to (must be path minus the directory BUT do not use  Quotations for this)(I also recommend using a single folder to hold the files while remuxing them before sending them  to their separate folders):
ffmpeg -i %IPath%  -c copy -map 0 "%M%:\%NewPath%"
goto :Premiere &:: This command takes inputs from the previous lines and sets up to remux files

:Premiere &:: this command line starts the preferred editor and waits 30 seconds to allow it to start
set /p EDITOR=Enter the .exe file for your prefered editor should look like: 'Adobe Premiere Pro.exe':
start "" "%EDITOR%"
echo Starting Process. . . Please Wait
timeout /t 30
tasklist | find /I "%EDITOR%" &:: The next couple of lines test for the editor to see if it opened or not
if errorlevel 1 (
     echo could not start process 
     goto :FailEditor
) Else (
     echo Process completed, next question--->
     goto :choice
)

so instead of starting at line 1 i would like to start at line 6 to bypass the longest section of the code.

Im thinking its something along the lines of

Start M:\REMUX.bat at line 6

however AT is a command to tell a time to start the batch file so im not sure


Solution

  • Yes, it is possible. Using an example script:

    @echo off
    if not "%~1" == "" goto :%~1
    :function1
    echo this is function 1
    :function2
    echo this is function 2
    :function3
    echo this is function 3
    

    You simply issue the label name as a parameter when you run the script, example:

    scriptname.cmd function2 which will skip function1