0

I am trying to figure out how to create a script that will take all video files in a folder videos\*.* and then use ffmpeg on each one and output the files to converted\*.mp4 where the filenames are the same.

However, I can't figure out how to get the for loop working, so that I can extract the name and extension type of file I am processing.

for %%f IN (videos\*.*) DO (convert.bat %%f)

convert.bat

ffmpeg.exe -i %1 -f mp4 converted\%~n.mp4

I have tried both with and without double quotes. However, it won't recognise the file.

1
  • Is there a typo on %~n.mp4? Commented Dec 27, 2012 at 15:08

1 Answer 1

5

One liner batch file command:

for %%F in (videos\*.*) do ffmpeg.exe -i "%%~fF" "%%~dpF\converted\%%~nF.mp4"

Two liner as you had it: (Added call command, quotations, and ~)

for %%F IN (videos\*.*) DO (call convert.bat "%%~fF")

convert.bat (Corrected parameter usage with ~, options, and quotations)

ffmpeg.exe -i "%~f1" "%~dp1\converted\%~n1.mp4"

See for /?, call /?, ffmpeg for help.

Sign up to request clarification or add additional context in comments.

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.