Passing parameters to the Linux utility "mediainfo"

Happy New Year to all!!!

I have a folder with a few thousand mp3 files, and I’m trying to export the entire folder contents’ to a simple text file, which I can then in turn import to LO’s Calc for further manipulation. The structure I’m trying to export this info to the text file is a very simple one, with each mp3 file listed in its own line, listing the file name first, then a comma and then the bitrate, as for example:

file1.mp3 , bitrate
file2.mp3 , bitrate
file2.mp3 , bitrate

I first tried the Linux command “file”, however, this command reports in a large number of cases an extremely erroneous bitrate, so I’m now attempting to use the command “mediainfo”, which yields a flawless output (as it regards bitrate) in all cases. My problem is in properly formatting the data when it’s being exported to the text file. The command I’m using is as follows:

$ mediainfo --Output=“General;%FileName%,%OverallBitRate%” *.mp3 > List_of_mp3_files.txt

Which does exactly what I want, except for the fact that the resulting text file is basically a single humongous line, with the data pertaining to each mp3 file followed by the next and so on, to the end. Therefore, it’s clear I need to force a carriage return somehow at the end of each file, to force the next file’s information to appear in a new line, however, I cannot think of a way to do this.

Any ideas would be greatly appreciated.


Did you try the obvious:

$ mediainfo --Output=“General;%FileName%,%OverallBitRate%\n” *.mp3 > List_of_mp3_files.txt

Thanks, freggel.doe, I hadn’t tried that, but just did.


$ mediainfo --Output=“General;%FileName%,%OverallBitRate%\n” *.mp3 > List_of_mp3_files.txt

and the return was:

Usage: “mediainfo [-Options…] FileName1 [Filename2…]”
“mediainfo --Help” for displaying more information
bash: fg: %FileName%,%OverallBitRate%n”: no such job

Notice that while the text returned by the command shows no back slash preceding the letter “n”, the command I ran did in fact had said back slash, exactly as you suggested.

So, no joy for now.

Ah, gotta love quoting:

$ mediainfo --Output='General;%FileName%,%OverallBitRate%\n' *.mp3 > List_of_mp3_files.txt

Man, o, man!!
I feel soooo stooopid!!!
Yeah, it works like a charm. Thanks a lot !!!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.