Bash-Script Implementation does not work properly [SOLVED]

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
AlphaInc.
Posts: 19
Joined: 15 Apr 2021 08:15

Bash-Script Implementation does not work properly [SOLVED]

#1 Post by AlphaInc. » 04 Aug 2021 06:40

Hello everybody,

I've been working on a mediainfo-Inform-template to better output certain information for different video files inside a folder. This is the template:

Code: Select all

General;File-Name...............: %CompleteName%\nFile-Size...............: %FileSize/String%\nDuration................: %Duration/String%\nOverall-Bitrate.........: %OverallBitRate/String%\n
Video;Video-Codec.............: %Format/String%\nVideo-Bitrate...........: %BitRate_Maximum/String%\nVideo-Auflösung.........: %Width%x%Height%\nVideo-Size..............: %StreamSize/String%\n
Audio;Audio-Langauge 1........: %Language/String%\nAudio-Format 1..........: %Format/String%\nAudio-Codec 1...........: %CodecID%\nAudio-Bitrate 1.........: %BitRate/String%-->%SamplingRate/String%<--\nAudio-Size 1............: %StreamSize/String%\n
Text;Text-Bitrate 1..........: %Language/String%\nText-Codec 1............: %Format/String%\nText-Bitrate 1..........: %BitRate/String%\nText-Size 1.............: %StreamSize/String%\n
File_End;\n--------------------------------------------------------------------\n                               File X\n--------------------------------------------------------------------\n\n
I used it by typing the following command on my Debian-Machine:

Code: Select all

mediainfo --Inform=file://template.txt *.mkv
And this was one example output:

Code: Select all

File-Name...............: video1.mkv
File-Size...............: 79.0 MiB
Duration................: 1 min 36 s
Overall-Bitrate.........: 6 893 kb/s
Video-Codec.............: AVC
Video-Bitrate...........: 12.7 Mb/s
Video-Auflösung.........: 1920x1080
Video-Size..............: 71.7 MiB (91%)
Audio-Langauge 1........: English
Audio-Format 1..........: E-AC-3
Audio-Codec 1...........: A_EAC3
Audio-Bitrate 1.........: 256 kb/s-->48.0 kHz<--
Audio-Size 1............: 2.93 MiB (4%)
Audio-Langauge 1........: English
Audio-Format 1..........: AAC LC
Audio-Codec 1...........: A_AAC-2
Audio-Bitrate 1.........: 125 kb/s-->48.0 kHz<--
Audio-Size 1............: 1.44 MiB (2%)
Audio-Langauge 1........: German
Audio-Format 1..........: E-AC-3
Audio-Codec 1...........: A_EAC3
Audio-Bitrate 1.........: 256 kb/s-->48.0 kHz<--
Audio-Size 1............: 2.93 MiB (4%)
Text-Bitrate 1..........: English
Text-Codec 1............: UTF-8
Text-Bitrate 1..........: 12 b/s
Text-Size 1.............: 87.0 Bytes (0%)
Text-Bitrate 1..........: German
Text-Codec 1............: UTF-8
Text-Bitrate 1..........: 7 b/s
Text-Size 1.............: 44.0 Bytes (0%)

--------------------------------------------------------------------
                               File X
--------------------------------------------------------------------
But when I try this with the exact same template on Windows although with a slightly different command:

Code: Select all

C:\System\Mediainfo\MediaInfo.exe --Inform=file://debug.txt *.mkv
I only get this output:

Code: Select all

--------------------------------------------------------------------
                               File X
--------------------------------------------------------------------
Does anyone know how I have to modify it to work? Since the template should (or am i wrong?) get handled by Mediainfo itself, I see no reason why the output is empty compared to me doing the same command in Debian
Last edited by AlphaInc. on 05 Aug 2021 09:57, edited 1 time in total.

ShadowThief
Expert
Posts: 1042
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Bash-Script Implementation does not work properly

#2 Post by ShadowThief » 05 Aug 2021 04:32

Your template displays information correctly for me in Windows (once I saved the CSV file as UTF-8 - MediaInfo didn't seem to like the ö in Auflösung when the file was saved as ANSI). If you pass your file to MediaInfo without specifying a CSV template, do you get information?

AlphaInc.
Posts: 19
Joined: 15 Apr 2021 08:15

Re: Bash-Script Implementation does not work properly

#3 Post by AlphaInc. » 05 Aug 2021 05:36

I tried it without my template and it does not work either.
But I discovered that if you specify the file it works (both with and without using m tempate) but not if you use *.mkv

So how do I run my mediainfo command for every *.mkv in my folder?

ShadowThief
Expert
Posts: 1042
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Bash-Script Implementation does not work properly

#4 Post by ShadowThief » 05 Aug 2021 05:52

Weird; I had wildcards working earlier and now I can't get them to work again. In any case, you can use a for loop to iterate over the contents of the folder:

Code: Select all

for %%A in (*.mkv) do mediainfo.exe --Output=file://template.txt "%%~A"

AlphaInc.
Posts: 19
Joined: 15 Apr 2021 08:15

Re: Bash-Script Implementation does not work properly

#5 Post by AlphaInc. » 05 Aug 2021 09:35

It tells me that "%%A" can not be processed syntax-wise at this point (I translated the output since it's in german: "%%A" kann syntaktisch an dieser Stelle nicht verarbeitet werden.)

AlphaInc.
Posts: 19
Joined: 15 Apr 2021 08:15

Re: Bash-Script Implementation does not work properly

#6 Post by AlphaInc. » 05 Aug 2021 09:57

Edit: My Bad, I made a mistake. Works fine now. Thank you.

Post Reply