• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: What is "system events" ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Re: What is "system events" ? (From: Jim Weisbin <email@hidden>)

  • Prev by Date: Re: What is "system events" ?
  • Next by Date: Re: AppleScript-Users Digest, Vol 14, Issue 479
  • Previous by thread: Re: What is "system events" ?
  • Next by thread: Re: What is "system events" ?
  • Index(es):
    • Date
    • Thread