I have many folders of mp3 files, and I would like to have a list of the combined duration of all the mp3s in each folder. That would be the ideal solution, but some means of doing a directory print attaching the individual mp3 duration would also be good. Any help would be much appreciated. I am running Windows 7 Home Premium, but have access to a number of other Windows/Mac OS.

Edit - I actually found an solution using the export function in the freeware program Tagscanner.

  • I have a WPF application I wrote that will do that (amongst other things), but I haven't uploaded it anywhere yet - still really for internal use only. However, if nothing else come up I could let you have a copy. – ChrisF Jan 11 '11 at 22:01

If you're working on Mac OS or any Unix system you can install ffmpeg and use the following command to extract the duration of a single file:

ffmpeg -i filename.mp3 2>&1 | egrep "Duration" | cut -d ' ' -f 4 | sed s/,//

That would for example return "00:08:17.4".

You can use this in a shell script of course, so for example this would list all of the mp3 files in a folder and their duration to the right.

# call me with mp3length.sh directory
# e.g. ./mp3length . 
# or ./mp3length my-mp3-collection

for file in $1/*.mp3
    echo -ne $file "\t"
    ffmpeg -i "$file" 2>&1 | egrep "Duration"| cut -d ' ' -f 4 | sed s/,//

You can get it easily with oneliner:

$ for file in *.mp3; do mp3info -p "%S\n" "$file"; done | paste -sd+ | sed 's+\(.*\)+(\1)/60+' | bc


  • mp3info: gets individual mp3 length in seconds
  • paste: merge column result with + as separator
  • sed: put () around sum and divides by 60 (minutes
  • bc: perform arithmetic operation

You can add a column to the file list in Wİndows Explorer. Add "Length" property colum to folder. Then select all off the mp3 files in the folder. You can see total length in the bottom summary pane of win.exp...

(Not the whole solution to your question but you said "any help would be appreciated :D)

  • Thanks, this is pretty much what I do at the moment. The problem is these files are across many hard drives, so I want to be able to export this info to use in spreadsheets and the like without doing it all manually. – Anastasia Jan 12 '11 at 6:49

A little late in the day (decade!), but I wanted to do exactly the same thing. Thanks to Windows Powershell, here is a little script that I wrote today.

$path = '~\MS Subbulakshmi\1. Toronto 1977\'
$shell = New-Object -COMObject Shell.Application
$folder = $path
$shellfolder = $shell.Namespace($folder)
$total_duration = [timespan] 0
foreach($file in Get-ChildItem $folder)
    $shellfile = $shellfolder.ParseName($file.Name)
    $total_duration = $total_duration + [timespan]$shellfolder.GetDetailsOf($shellfile, 27);
Write-Host "Total Duration of $folder is $total_duration"

The output would be something like this

Total Duration of ~\MS Subbulakshmi\1. Toronto 1977\ is 01:52:28

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.