Jump to content

Can someone help me with some code in this script?


1971camaroguy

Recommended Posts

1971camaroguy

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

rbjtech

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 by rbjtech
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...