1971camaroguy 24 Posted April 7, 2023 Share Posted April 7, 2023 I have this batch script I use to convert various video files by changing the extensions in the script using mkvtoolnix. It works great but I wanted to add a line of code but not sure how to do this. Right now the script looks for any files with mp4 extensions and converts them to mkv. But leaves both copies in there. I am trying to add a line of code, that after it converts the mp4 to mkv, it deletes any mp4 files left in the folders and subfolders after the conversion. Anyone know what I need to add and where in this? Thanks again! @echo off FOR /F "delims=" %%A in ('dir /a-s /b /s "*.mp4"') DO ( echo input : "%%A" echo output : "%%~dA%%~pA%%~nA-remux.mkv" "C:\Program Files\MKVToolNix\mkvmerge.exe" -o "%%~dA%%~pA%%~nA-remux.mkv" "%%A" if %errorlevel% equ 0 ( setlocal EnableDelayedExpansion echo [!date! !time:~0,8!] OK - "%%~dA%%~pA%%~nA.mkv" >> remux.txt endlocal echo Deleting "%%A" rem del "%%A" ) else ( setlocal EnableDelayedExpansion echo [!date! !time:~0,8!] ERROR! - "%%~dA%%~pA%%~nA.mkv" >> remux.txt endlocal ) ) pause Link to comment Share on other sites More sharing options...
rbjtech 4314 Posted April 7, 2023 Share Posted April 7, 2023 (edited) Just remove the 'rem' from line 12 (leaving the del "%%A" part) adding 'rem' (remark) at the start of a line means it will not be executed. the 'del' command will remove the original mp4 file if the mkvmerge was successful. Looks like one of my batch scripts ... lol Edited April 7, 2023 by rbjtech Link to comment Share on other sites More sharing options...
1971camaroguy 24 Posted April 7, 2023 Author Share Posted April 7, 2023 awesome, thank you! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now