# Ubuntu – List the duration of each video file in a directory

filemanagervideo

I have a directory full of .MP4 video files. I would like to see a list that has the name of each file and its duration in minutes and seconds. Something like this:

one.mp4    4:34
two.mp4    2:23
three.mp4  8:34
four.mp4   0:43


I have tried many file managers but cannot find one that will show me this information.

Solutions that involve the terminal would be fine.

Try this: (inspiration from superuser.com)

for f in *.mp4
do
echo -n "$f " ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 -sexagesimal "$f"
done


However, output will be in the form HH:MM:SS.MILLISECONDS. If you leave out the option -sexagesimal, you will get the duration in seconds.

For the desired outputform HH:MM, you could do something like this:

for f in *.mp4
do
echo -n "$f " dur=ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "$f"
min=echo "$dur/60" | bc sec=echo "$dur%60/1" | bc
echo "$min:$sec"
done