Velvet Star Monitor

Standout celebrity highlights with iconic style.

news

Unable to call ffmpeg in a batch file

Writer Matthew Harrington

I reencode a lot of video files with ffmpeg using the following command at the prompt:

for %F in ("..\*.*") DO ffmpeg -n -i "%F" -c:v libx265 -c:a copy "%~nF.mkv"

I created a batch file containing this command and put it in my profile path. But when I run it, I get the following:

M:\>ff.bat
The following usage of the path operator in batch-parameter
substitution is invalid: %~nF.mkv"
For valid formats type CALL /? or FOR /?
The syntax of the command is incorrect.
M:\>for F" -c:v libx265 -crf 28 -c:a copy "F" -c:v libx265 -crf 28 -c:a copy "%~nF.mkv"

A problem with quote marks maybe?

2 Answers

A problem with quote marks maybe?

No. it's a problem with %. On the command line use a single %. In a batch file double it up %%.

So use the following:

for %%F in ("..\*.*") DO ffmpeg -n -i "%%F" -c:v libx265 -c:a copy "%%~nF.mkv"

If you are using the FOR command at the command line rather than in a batch program, use just one percent sign: %G instead of %%G.

Source: For - Looping commands - Windows CMD - SS64.com


Further Reading

Exactly you have to use double percentage signs instead of single. Also make sure the ffmpeg paht is in the %path% variabel of you have to specify the whole path to ffmpeg program....

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy