I'm looking for an easy way to print to a file the following information in a directory full of video files:

File Name, File Type, Video Length (in Seconds)

I realize the first two are very easy, its the 3rd bit of information that I'm having trouble finding an automated way to accomplish.


You may install the command line utility exiftool.

Then open a text file and copy/paste the following bash script:


find "~/Movies/" -name "*" -not -name ".*" -type f | while read file
    FILETYPE=$(exiftool  -p "\$FileType" "${file}")
    FPS=$(exiftool  -p "\$FrameRate" "${file}")
    TOTALFRAMES=$(exiftool  -p "\$FrameCount" "${file}")
    echo ${file} ${FILETYPE} ${DURATION} > output.txt

Replace ~/Movies/ with the full path containing the movie files and output.txt with your resulting file name.

Save the file to your user's home folder, as 'meta_generator' or by whatever name you want.

Then fire up /Utilities/Terminal.app and type:

chmod +x meta_generator

Edit: I just saw that you wanted the length in seconds, so I've replaced the Duration tag.

By multiplying the framerate and the total frame count, you'll get the desired seconds..

But you may find other easier ways though :)

  • You could trim out the DIR= line, and replace "${DIR}" with a simple ~/Movies/ if you want. – Jason Salaz Mar 30 '11 at 23:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .