Automatically insert .mkv filename into .bat file
Automatically insert .mkv filename into .bat file
I'm trying to write a quick 'n dirty .bat file that will detect the filename of an mkv file in a directory and automatically insert that name into the .bat file (am piping the .mkv through ffmpeg). The .bat file will be in my path so that I can use it in any directory. Does anyone know how to do this?
Re: Automatically insert .mkv filename into .bat file
Assuming by "bat file" you mean Windows... This might be a good start.
MakeMKV Frequently Asked Questions
FAQ about BETA and PERMANENT keys.
How to aid in finding the answer to your problem: Activating Debug Logging
FAQ about BETA and PERMANENT keys.
How to aid in finding the answer to your problem: Activating Debug Logging
Re: Automatically insert .mkv filename into .bat file
Thanks! Looks kinda tricky, but I'll give it a shot!
Re: Automatically insert .mkv filename into .bat file
Here's an example I had archived. Just modify the path to the ffmpeg executable & ffmpeg arg defs ('SET ...') to your preference:
Currently, it'll do nothing when executed except...
- Find ANY .mkv below wherever you execute the .bat
- Print the ffmpeg command line to convert the .mkv to.mp4 in the same folder (remove 'ECHO ' to actually execute the conversion)
- The next line will remove the original .mkv IF the conversion is successful (remove 'REM ' if deletion is desired)
& let you experiment w/ some of those strange args the tutorial describes. Hope this helps?
Code: Select all
@ECHO OFF
SET "FFMPEG=C:\Users\username\AppData\Roaming\Emby-Server\system\ffmpeg.exe"
SET "VCODEC=-vcodec copy"
SET "ACODEC=-acodec copy"
REM SET "SCODEC=-scodec copy"
FOR /r %%F IN (*.mkv) DO (
ECHO "%FFMPEG%" -i "%%F" %VCODEC% %ACODEC% %SCODEC% "%%~dpnF.mp4"
REM IF NOT ERRORLEVEL 1 IF EXIST "%%~dpnF.mp4" DEL /Q "%%F"
)
- Find ANY .mkv below wherever you execute the .bat
- Print the ffmpeg command line to convert the .mkv to.mp4 in the same folder (remove 'ECHO ' to actually execute the conversion)
- The next line will remove the original .mkv IF the conversion is successful (remove 'REM ' if deletion is desired)
& let you experiment w/ some of those strange args the tutorial describes. Hope this helps?