using Applescript to retrieve movie file duration via Finder properties
- by Matt
When using Get Info on movie files in the Finder, I've noticed that many movie files have an accessible "Duration" property under the More Info tab. Is there an easy way to access this data using Applescript? I've tried lines like "set theTime to (duration of aFile)", but it doesn't seem to be as simple as that.
Ideally I'd like to access the movie duration via the Finder properties without having to actually open the file in QuickTime. Is this possible?
Edit:
I seem to have figured this out... you need to use the "System Events" application, specifically the Movie File Suite of commands (and, importantly, you need to set the movie variable as a string, rather than an alias):
set theMovie to (choose file with prompt "Select a movie file:") as string
tell application "System Events"
set theName to name of movie file theMovie
set theDuration to (duration of contents of movie file theMovie) / (time scale of contents of movie file theMovie)
end tell