1

I'm a virgin to this whole CMD scene. I can really use some help. I just want to delete the file after it converts. Heres what I have so far: update: I figured how to delete after conversion, but its after everything is converted, I want to delete the file RIGHT AFTER EACH CONVERT...

dir/b/s *.mkv >mkvlist.txt
for /F "delims=;" %%F in (mkvlist.txt) do ffmpeg.exe  -i "%%F" -vcodec copy -acodec copy "%%~dF%%~pF%%~nF.mp4"
del mkvlist.txt del *.mkv

2 Answers 2

5

There is not any need for the temporary file. Just use a recursive for command, and for each file found, convert it and remove source if the output file exists and no error was reported

for /r %%F in (*.mkv) do (
    ffmpeg.exe  -i "%%F" -vcodec copy -acodec copy "%%~dpnF.mp4"
    if not errorlevel 1 if exist "%%~dpnF.mp4" del /q "%%F"
)
Sign up to request clarification or add additional context in comments.

7 Comments

Ha! It works , but the audio is still in dts, is there a way to convert the audio too, I'm trying to convert to ACC format. I'm trying to get direct streams for Plex. Thanks for your time MC you have no idea how much I appreciate it.
@Gsharks, if you want to convert the audio you should not directly copy it from input file. Try replacing -acodec copy with -c:a aac, or read here for more information
You are a blessing sir, I don't have much to offer but I will send you my username to plex, u can use it..u have earned a lifetime membership;-)
Don't see a way to send u an private msg, so here's my username torres3490, send me a friend request but let me know your username here so I don't except some random person
Be aware that sometimes ffmpeg will create a file, including an empty one, and leave it there, even if conversion has failed. Better to check for error code, so last line in the loop could be if %errorlevel%==0 del /q "%%F"
|
1

CMD use && chars to run command if previous completed successfully. For example I use the following

for %i in (*.avi) do ffmpeg -sn -y -i "%i" -c:v libx265 -c:a aac "%~ni.mp4" && del /f/q "%i"

Code all avi files in folder and delete source file after successfull.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.