2

I want to use Mediainfo with a bat file. It should write the Media Info into a textfile, then rename the file to *.nfo That works quite good, but I always get the complete "standart" Media Info, not a custom one that I need. Here is my code so far:

@echo off

set "mediainfo_path=C:\Program Files\mi cli\MediaInfo.exe"
set "output_extension=C:\Program Files\mi cli\custom.txt"
cd %1
echo.
echo Looking for Media Assets on target directory . . .
REM  ******** Add media file extensions here ********
dir *.mkv /b /s > filelist.tmp
REM  *
REM  ******* Loop through temporary file list *******
(for /f "delims=" %%i in (filelist.tmp) do (
echo Extracting %%i metadata information . . .
setlocal enabledelayedexpansion
"!mediainfo_path!" --logfile="!output_extension" "%%i" > %%i.nfo

echo()
endlocal
)
del filelist.tmp

echo.

o matter what "output_extenstion" I choose, the result is always the same, full log.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Mueslie
  • 21
  • 1
  • 2

1 Answers1

1

First, you need to do step by step, so start by trying the MediaInfo command without the batch stuff. You'll see that it does not work. "--logfile" is for storing the output (similar to your ">%%i.nfo") so you did not say to MediaInfo that you want a custom report.

mediainfo --Output=file://custom.txt a.mkv >a.nfo

or

mediainfo --Output=file://custom.txt a.mkv --LogFile=a.nfo

Would work as you expect (the first version both show and store info, the second version only store info).

So replace the "MediaInfo line" by:

"!mediainfo_path!" "--Output=file://!output_extension!" "%%i" > %%i.nfo

and it works as you expect.

Note: I am aware that there is a lack of documentation, due to lack of time :(.

Jérôme, developer of MediaInfo

Jérôme Martinez
  • 1,118
  • 5
  • 10
  • unfortunally not - the created file looks like this: Usage: "MediaInfo [-Options...] FileName1 [Filename2...]" "MediaInfo --Help" for displaying more information – Mueslie Nov 16 '16 at 18:27
  • I copied/pasted your typo ;-). Comment edited with the missing "!" added. – Jérôme Martinez Nov 16 '16 at 18:42
  • Im sorry, but still i get only the complete output and not a custom.... regardless en.Example.csv or XML.csv......... – Mueslie Nov 16 '16 at 19:03
  • Comment edited again with moving a quote in the initial code to the right place. Note that this is batch stuff, no more MediaInfo (please test first with MediaInfo alone). also en.Example.csv provokes a crash when I test, there are some known issues with templates but no time for fixing it; your template may be good, test it first with MediaInfo on the command line in order to see if it is OK before using your batch. – Jérôme Martinez Nov 16 '16 at 19:39
  • Sorry, but what for is the MediaInfo CLI if not for batch? I dont kow what you mean "Test with Mediainfo". I usually use the GUI for exporting and then renaming manually. And that works great. Now I try to get the same done automatically with the CLI. It just seems like there is no template called, no matter what output extension is called, even if the file does not exist, and i assume that if so, the standart one will be used. But why? :) – Mueslie Nov 16 '16 at 21:40
  • CLI is for batch but as for any other command it is better to test it standalone before playing with batches. I run your script (with my modification) and it does the job, see https://gist.github.com/JeromeMartinez/d54cfb4c7565d26ad5bbbc60c98cb3c0 for the exact commands and the exact files I used. After that, you are the one who can decide what to put in the template file. – Jérôme Martinez Nov 17 '16 at 08:47
  • I dont understand that. I do exactly the same, I even moved CLI to C:\MediaInfo_Custom. I execute the bat and it give the full mediainfo. No the custom.... argh – Mueslie Nov 17 '16 at 10:18
  • The funny part is, I can not change anything how the output file looks like. even if the outputfile does not exist at all. – Mueslie Nov 17 '16 at 11:11