Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

You may install the command line utility exiftool.

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

#!/bin/sh

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

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
./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 :)

share|improve this answer
    
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
    
@vxjasonxv Thank you for your proposal :) –  nuc Mar 31 '11 at 9:39
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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