3

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 2

6

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

0

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
  • 1
    %path% has nothing to do with the problem.
    – DavidPostill
    Commented Apr 23, 2021 at 20:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .