Re: What is "system events" ?
Re: What is "system events" ?
- Subject: Re: What is "system events" ?
- From: Shane Stanley <email@hidden>
- Date: Sat, 21 Oct 2017 22:56:14 +1100
On 21 Oct 2017, at 5:48 am, Jim Weisbin <email@hidden> wrote:
>
> Here’s something I use a lot. Using System Events, I can get the duration of
> an audio file without having to open, say, Quicktime, and it’s GUI:
FYI, if you're doing it a lot, something like this is considerably quicker:
use AppleScript version "2.5" -- 10.11 required
use framework "Foundation"
use framework "AVFoundation"
use scripting additions
set theFile to (choose file)
set theAsset to current application's AVAsset's assetWithURL:theFile
set N to theAsset's |URL|()'s lastPathComponent() as text
set theDuration to theAsset's duration()
set t to (theDuration's value) / (theDuration's timescale)
set theFormatter to current application's NSDateComponentsFormatter's new()
(theFormatter's stringFromTimeInterval:t) as text
--
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>, <latenightsw.com>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden