Page 1 of 1

Set Global and "local" Counter [SOLVED]

Posted: 06 Aug 2021 04:56
by AlphaInc.
Hello everybody,

I have created a template for MediaInfo to output specific information about the video files inside a specific folder. The output will then be written to a txt-file.
This is the command I Use:

Code: Select all

for %%A in (*.mkv) do C:\System\Mediainfo\MediaInfo.exe --Inform=file://C:\System\Mediainfo\template1.txt %%A >> Output1.txt
for %%A in (*.jpg) do C:\System\Mediainfo\MediaInfo.exe --Inform=file://C:\System\Mediainfo\template2.txt %%A >> Output2.txt
the template (template1.txt) for MKV's looks like this:

Code: Select all

General;--------------------------------------------------------------------\n%fileCounter%\n--------------------------------------------------------------------\n\nFile-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 %audioCounter%........: %Language/String%\nAudio-Format %audioCounter%..........: %Format/String% (%CodecID%)\nAudio-Bitrate %audioCounter%.........: %BitRate/String% (%SamplingRate/String%)\nAudio-Size %audioCounter%............: %StreamSize/String%\n
Text;Text-Bitrate %textCounter%..........: %Language/String%\nText-Codec %textCounter%............: %Format/String%\nText-Bitrate %textCounter%..........: %BitRate/String%\nText-Size %textCounter%.............: %StreamSize/String%\n
File_End;\n
And the template (template2.txt) for JPGs looks like this:

Code: Select all

General;--------------------------------------------------------------------\n%fileCounter%\n--------------------------------------------------------------------\n\nFile-Name...............: %CompleteName%\nPhoto-Codec.............: %Format/String%\n
Image;Photo-Auflösung.........: %Width%x%Height%\nPhoto-Size..............: %StreamSize/String%\n
File_End;\n
Now i want to expand this by setting different counters. I want the script to count for all files (it should just go File 1, File 2, File 3, etc.) and also the different audio and text-information but for those two, the counter should be reset after every file. I thought about something like this but I'm not sure how to do:

Code: Select all

set /A fileCounter=0 for
   set /B audioCounter=0
   set /C textCounter=0
      for %%A in (*.mkv) do C:\System\Mediainfo\MediaInfo.exe --Inform=file://C:\System\Mediainfo\template1.txt %%A >> Output1.txt
   set /B audioCounter=0
   set /C textCounter=0
      for %%A in (*.jpg) do C:\System\Mediainfo\MediaInfo.exe --Inform=file://C:\System\Mediainfo\template2.txt %%A >> Output2.txt
   set /B audioCounter=0
   set /C textCounter=0
But that specific code did not work (it outputs the file and leves everything empty where my counters have been set, probably because the mediainfo template uses this kind of syntax.

Re: Set Global and "local" Counter

Posted: 06 Aug 2021 11:32
by aGerman
Don't get it, sorry. However, there's no such things like SET /B or SET /C.

Steffen

Re: Set Global and "local" Counter

Posted: 06 Aug 2021 12:32
by AlphaInc.
What I meant is to set a counter (With SET /B and SET /C I was trying to set a counter in the head of the tool and define it as 0 to later increase)

When executing the commands listed in the script the counter should increase with every file (fileCounter) respectively every audio (audioCounter) and Subtitle (textCounter).

Re: Set Global and "local" Counter

Posted: 06 Aug 2021 12:54
by IcarusLives
You're missing the entire fundamental of set /a.

Code: Select all

set /a "var=1"

set /a "var[1]=var + 1"
set /a "var[2]=var[1] + 2"

set /a "var+=1"
You don't change the command. You create an array and add to each variable accordingly.

Re: Set Global and "local" Counter

Posted: 06 Aug 2021 13:23
by ShadowThief
The "a" in "set /a" is short for "arithmetic."

Re: Set Global and "local" Counter

Posted: 06 Aug 2021 13:52
by AlphaInc.
Ah okay, that's how i set the counter. And do i implement "var" in a text file to increase ?

I even have troubles to even increase the counter for fileCounter (as shown in my mediainfo-template. When I execute the script like that the line stays empty without anything.

Code: Select all

@echo off

set /a fileCounter=0
	for %%A in (*.mkv) do (
		set /a fileCounter=fileCounter+1
		C:\System\Mediainfo\MediaInfo.exe --Inform=file://debug.txt %%A >> Output1.txt
		)
exit