1

I have a bunch of mp4 files in a folder and I want to create a text file with all the names and the length of the files as in:

01_Welcome.mp4 00.01.23
02_Tools.mp4 00.03.12

I know how to read the names of the files buy how do I get the length attribute? When I click a file the length appears in the status bar, so there should be a way to read that property. And I would like to do it from the command line, not through a third-party package.

JosefZ
  • 28,460
  • 5
  • 44
  • 83
Ivan Yosifov
  • 59
  • 1
  • 6

2 Answers2

2

In ubuntu there you can

 ffmpeg -i myvideo 2>&1 | grep Duration | cut -d ' ' -f 4 | sed s/,//

But in Windows MediaInfo is the one option

Anptk
  • 1,125
  • 2
  • 17
  • 28
  • 1
    Yes, I'm using Windows and I was hoping there was some sort of batch magic that could help, but I'll give this MeidaInfo a try. Thanks. – Ivan Yosifov Aug 21 '15 at 09:56
0

In Windows' PowerShell you can do the following to extract length of a single media file:

$Folder = 'C:\Path\To\Parent\Folder'
$File = 'Video.mp4'
$LengthColumn = 27
$objShell = New-Object -ComObject Shell.Application 
$objFolder = $objShell.Namespace($Folder)
$objFile = $objFolder.ParseName($File)
$Length = $objFolder.GetDetailsOf($objFile, $LengthColumn)

Iteration over the folder content is left as an exercise for the reader.

Source

Przemek D
  • 654
  • 6
  • 26