1

I have a problem with a console command executed from within a batch file in a command prompt window on Windows 7. I want to get the frame rate and the number of audio streams of a video and write them into a text file. For the frame rate there is no problem, I run this command from a batch file:

for %%a in (C:\Documents) do (
    echo.
    Mediainfo --Inform=Video;%%FrameRate%% %%a
)>> "D:\TestFrame2.txt"

But for the number of audio streams, it returns an empty text and there is no error message. I use exactly the same batch file, but I replaced Video by Audio and FrameRate by StreamCount.

I see these parameters when I run Mediainfo --Help-Inform.

And also a lot of others options like Mediainfo --Inform=General;%%AudioCount%% don't work.

I have tested already to replace Inform by Output and there is no change. And I have tested also to use this command directly in the console window without redirecting the results into a text file and it's the same thing.

What is the reason for not getting number of audio streams written to the text file?

Mofi
  • 46,139
  • 17
  • 80
  • 143
Babadi48
  • 11
  • 1
  • 3
  • 1
    `for %%a in (C:\Documents) do echo %%a` gives `C:\Documents` - and nothing more. Is that, what you want? – Stephan Sep 11 '15 at 15:05
  • FYI: It's not Ms Dos, it's the Windows Command Prompt. MS-DOS was an operating system, and so is Windows 7. – Shotgun Ninja Sep 11 '15 at 15:08
  • Ho I'm really sorry I did an error in my message. For my command I don't use (C:\Documents) but (C:\Documents\*.mov). – Babadi48 Sep 14 '15 at 10:58

2 Answers2

2

Use MediaInfoCLI to redirect its output to a file, and there's no need to enumerate the files as the program can do it.

  • List frame rates without file names:

    pushd c:\documents
    "C:\Program Files (x86)\MediaInfo\MediaInfoCLI" --output=Video;%%FrameRate%%\r\n ^
        *.mpg *.mp4 *.mkv *.avi *.m4a *.flac *.mp3 *.wav >"D:\TestFrame2.txt"
    popd
    
  • List filenames and frame rates separated by : (note that as it fetches info from multiple MediaInfo sections a template file is required):

    pushd c:\documents
    (
        echo General;%%FileName%%%%FileExt%%:
        echo Video;%%FrameRate%%\r\n
    ) >"%temp%\mediainfotemplate"
    
    "C:\Program Files (x86)\MediaInfo\MediaInfoCLI" ^
        --output="file://%temp%\mediainfotemplate" ^
        *.mpg *.mp4 *.mkv *.avi *.m4a *.flac *.mp3 *.wav >"D:\TestFrame2.txt"
    
    del "%temp%\mediainfotemplate"
    popd
    

Instead of the explicit file type list you can use * to process all files.

wOxxOm
  • 65,848
  • 11
  • 132
  • 136
  • Thanks for your respond but I have an error message "access denied". So I run the file as administrator but I have the same message. It's the same thing if I run the command directly from the command prompt as administrator.. It's weird because normally I have all rights. – Babadi48 Sep 14 '15 at 12:45
  • @Babadi48, follow the standard procedure: remove/comment any `echo off` lines, execute the batch file from a Command Prompt console and check the command which produces the error. – wOxxOm Sep 14 '15 at 12:49
0

. C:\Documents is a folder, you have to specify a mask like *.*, *.txt, my-video-??.* or *.mp4 *.avi

Example for video AVI.

(for %%a in (C:\Documents\*.avi) do (echo fake-command %%a)
)>_TestFrame2.txt
Paul
  • 2,620
  • 2
  • 17
  • 27
  • Thanks for your respond, I already test that. In my first post I forgot to write (C:\Documents\ ***.avi**). So it doesn't work. For the Frame Rate it's OK but with Audio StreamCount and a lot of others commands it return nothing without error message... – Babadi48 Sep 14 '15 at 12:00