Get song duration from an mp3 file in a script?
Solution 1:
To get the length of an mp3, probably the easiest way is to make use of what explorer uses, a Shell objekt.
I'm afraid I don't have a one-liner for you, but you can always make a script that you call.
$path = 'M:\Musikk\awesome_song.mp3'
$shell = New-Object -COMObject Shell.Application
$folder = Split-Path $path
$file = Split-Path $path -Leaf
$shellfolder = $shell.Namespace($folder)
$shellfile = $shellfolder.ParseName($file)
write-host $shellfolder.GetDetailsOf($shellfile, 27);
More information can be found here: http://powershell.com/cs/blogs/tobias/archive/2011/01/07/organizing-videos-and-music.aspx
Edit: The reason this method is necessary is because the length information resides with the other metadata of the file.