Page 1 of 1

How to modify this MediaInfo CLI Batch?

Posted: 04 Mar 2019, 15:11
by Scr1pter
Hi guys,

I would like to create a list which contains filename and formatted time (mp4 files).
So far, I've been able to retrieve a list whose result is acceptable:
Batch file:

Code: Select all

@ECHO off
CLS
C:\Users\USER\Downloads\MediaInfo_CLI_18.12_Windows_x64\MediaInfoCLI.exe --output=General;%%FileName%%^|%%Duration%%\r\n *.mp4 --LogFile=MP4_NameAndDuration.txt
PAUSE
.
The result is for example this:

Code: Select all

01. Schwert|1485311
02. Pfeile|1335798
03. Bogen|1675808
.
I know there are different types of duration, but I prefer to have milliseconds because I can modify it afterwards as I want.
My aim would be that the final list looks like this:

Code: Select all

01. Schwert (25 Min)
02. Pfeile (22 Min)
03. Bogen (28 Min)
.
I already created an AHK script which reads in data and change the format, like:

Code: Select all

F8::
FileRead, all, C:\Users\USER\Documents\Lernmaterial\Videos\MP4_Duration.txt ; Read whole file and assign its data to variable "all"
Loop, Parse, all, `n, `r ; Parse the freshly read in data on each line-break
{
  formatedTime := A_LoopField / 1000 / 60 ; Make Minuntes out of milliseconds
  saveLine .= " (" . Round(formatedTime) . " Min)`r`n" ; Add formated string + rounded number + string to variable (e.g. from 1000000 ->  (17 Min))
}
Clipboard := saveLine ; Assign all merged lines to the Clipboard
ClipWait, 0.1 ; Wait 100 ms until Clipboard contains data
return
.
I would only need to merge 2 text files, but I wonder, can I probably just modify the batch file so that I save all this additional work?
Unfortunately, I have 0 clue regarding that programing language.
My idea was something like:

Code: Select all

@ECHO off
formatedDuration = Duration / 1000 / 60
CLS
C:\Users\USER\Downloads\MediaInfo_CLI_18.12_Windows_x64\MediaInfoCLI.exe --output=General;%%FileName%%^(%%formatedDuration%% Min)\r\n *.mp4 --LogFile=MP4_NameAndDuration.txt
PAUSE
.
However, that failed completely:

Code: Select all

01. Schwert(02. Pfeile(03. Bogen
Thanks for any help!

Cheers!

Re: How to modify this MediaInfo CLI Batch?

Posted: 09 Mar 2019, 11:43
by Scr1pter
Topic solved differently.
I simply read in a file, change the milliseconds and send the content to the Clipboard.
A solution I can live with!

Code: Select all

Datei_Komplett_Einlesen(zielDatei) ; Eine Datei mittels FileRead komplett einlesen - #FUNKTION#
{
  FileRead, alles, %zielDatei% ; Datei vollständig einlesen und Inhalt in Variable "alles" speichern
  Loop, Parse, alles, `n, `r ; Zeichen anhand Zeilenumbrüche trennen
  {
    stringArray := StrSplit(A_Loopfield, CHR(124)) ; Werte anhand des | splitten/trennen (stringArray[1] = Dateiname, stringArray[2] = Millisekunden
    minuten     := stringArray[2] / 1000 / 60 ; Millisekunden in Minuten umwandeln
    neuerString .= stringArray[1] . " (" . Round(minuten) . " Min)`r`n" ; Neu formatierte und gerundete Zeile der Variable hinzufügen
  }
  StringTrimRight, Clipboard, neuerString, 11 ; Die letzten 11 Zeichen (unnötige Leerzeile + (0 Minuten) abschneiden und Inhalt an die Zwischenablage senden
  ClipWait, 0.1 ; 100 ms warten, dass die Zwischenablage Daten enthält
}
Cheers!