On Oct 24, 2011, at 13:52, Bob Majors wrote: Before I dive in, I thought I'd ask if anyone here has AppleScript code (and/or an Automator Workflow) that would walk through a folder of audio or video files (.aif or .mov for audio; .mov for video), get their length (and perhaps other information (encoding?)), then write out the filename and length to a structured text file. Thanks.
______________________________________________________________________
Hey Bob,
I think I'd use the ExifTool for this job.
This script operates on the Finder selection (of movie files), but it'd be simple to change to work with folders.
set movieInfo to "" try tell application "Finder" set sel to selection as alias list if sel ≠ {} then set fSel to first item of sel end if
repeat with i in sel set movieFile to quoted form of (POSIX path of i) set cmd to "exiftool " & movieFile & " | egrep -i '^Duration|File Name|Video Encoding'" set movieInfo to movieInfo & (do shell script cmd) & linefeed & linefeed end repeat end tell
# Write to file...
on error errMsg number errNum set {cr, sep} to {return, "------------------------------------------"} set e to sep & cr & "Error: " & errMsg & cr & sep & cr & "Error Number: " & errNum & cr & sep beep display dialog e end try
-->" File Name : Here's to the Crazy Ones.flv Duration : 0:01:00 Video Encoding : H.264
File Name : Steve Jobs Commencement Address at Stanford 2005.flv Duration : 0:15:04 Video Encoding : H.264
File Name : The Lost 1984 Video - young Steve Jobs introduces Macintosh.flv Duration : 0:05:10 Video Encoding : H.264
"
Here's an example of a full data record:
ExifTool Version Number : 8.61 File Name : The Lost 1984 Video - young Steve Jobs introduces Macintosh.flv Directory : /Users/chris/Movies/Steve Jobs File Size : 11 MB File Modification Date/Time : 2010:07:05 04:40:13-05:00 File Permissions : rw-r----- File Type : FLV MIME Type : video/x-flv Duration : 0:05:10 Start Time : 0 s Total Duration : 310.2 Image Width : 320 Image Height : 240 Video Bitrate : 238 kbps Audio Bitrate : 63.2 kbps Total Data Rate : 308678 Frame Rate : 25.003 Byte Length : 11990298 Can Seek On Time : Yes Source Data : BADDBA70BHH1317945194139097 URL : Message : HTTP Host Header : o-o.preferred.suddenlink-dfw1.v16.lscache6.c.youtube.com Video Encoding : H.264 Audio Encoding : AAC Audio Sample Rate : 44100 Audio Bits Per Sample : 16 Audio Channels : 2 (stereo) Image Size : 320x240
* Note that the data record is not fixed-format, so fields may appear/disappear according to the available information.
-- Chris
|