I'm creating a batch file to automate FFmpeg remuxing and other tedious steps within. i also want to distribute this batch file out to others because it seems like it would be useful to others like minded.
In my code I have it open up an application in an early part of it so that the user of the code can open their preferred editor and test if their file works as intended, then continue with the code however once it opens the application the batch file stops and completely closes.
TL;DR: How do I keep the batch window open after running the start command?
I will post the first 2 code blocks below so that you can see what I mean:
@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):
set /P f=have you accidentally closed the process?[y/N] Please note this will skip the remuxing process and take you through the rest of the code:
if /I "%f%" == "N" goto :FFmpeg
if /I "%f%" == "Y" goto :Premiere
:FFmpeg
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':
echo Starting Process. . . Please Wait
start "" "%EDITOR%"
echo Starting Process. . . Please Wait
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
)
Update: I have found using the cmd /k
just before that command will keep the window open but it doesn't continue the code, it just opens the application then goes to the directory I specified
Update 2 I have tried the /wait
command per Raven
(Thank You by the way that will come in handy in the future) but all it did on my code was wait for the application to close then it closed the batch file. I would like to clarify that I'm trying to continue the code from where it left off after opening the application. else the rest of the code is pointless.
Update 3 After more testing it seems the code just stops abruptly now before opening my Editor (albiet this was an older version) here is the code for it
@Echo off
Setlocal
set /p newname=Enter new file name:
set /p k= keeps breaking?[Y/N]
if /I "%k%" == "Y" goto :Premeiere
if /I "%k%" == "N" goto :start
:start
ffmpeg -i "V:\Before Remux\01.mkv" -c copy -map 0 "M:\1 REMUX HUB\%newname%.mp4" /wait
goto :Premeiere
:: this command line starts premiere pro and waits 1 minute to allow it to start
:Premiere
start "Editor" "Adobe Premiere Pro.exe"
pause
goto :choice
:choice &:: This asks user to check using premiere pro or other editing sofware for corruption/file failure
set /P c=Does the final file work as intended[Y/N]?
if /I "%c%" == "N" goto :Redo &:: this will send them to Redo the remux
if /I "%c%" == "Y" goto :Foldercreation &:: if no failure/corruption is found and user confirms this will send them to :Delete
:Redo &:: This command line re-remuxes the original video then asks the question again
ffmpeg -i "V:\Before Remux\01.mkv" -c copy -map 0 "M:\1 REMUX HUB\%newname%%%.mp4"
goto :choice2
:Foldercreation &:: This section asks the user which folder it should be stored in
set /P Folder=Which folder should this go in?
echo Checking if exists directory "M:\%Folder%" ...
cd "M:\%Folder%"
if !ERRORLEVEL! GTR 0 (
echo Directory doesn't exist, creating...
md "M:\%Folder%"
goto :Foldercreation
) else (
echo Directory already exists.
)
goto :Move
:Move
move "M:\1 REMUX HUB\%newname%.mp4" "M:\%Folder%\"
set /P c3=Did the file go to the correct folder?[Y/N]
if /I "%c3%" == "Y" goto :Delete
if /I "%c3%" == "N" goto :Foldercreation
:Delete &:: This area deletes the original file to allow obs to write the next one without issue
Del "V:\Before Remux\01.mkv"
echo This video is now remuxed please edit it
echo OBS is primed for next stream!!
pause
endlocal
exit
:choice2 &:: This asks the user again just in case
set /P c2=Does this one work? If not check for corruption in original file!!![Y/N]
if /I "%c2%" == "N" goto :corrupted
if /I "%c2%" == "Y" goto :Foldercreation
:corrupted &:: if FFmpeg fails both times user is asked to check for corruption and does not delete the original file
@Echo check for corruption
pause
endlocal
exit
Update 4: I have since found out the reason it was stopping. it was becasue i mislabled with a single letter which broke the code and stopped the program immediately. I have also learned how to debug using pause commands. thank you for helping me