• 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: Durations of mp3 files?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Durations of mp3 files?


  • Subject: Re: Durations of mp3 files?
  • From: Jim Weisbin <email@hidden>
  • Date: Fri, 8 Dec 2006 10:08:27 -0500

Here's what I use:

property extension_list : {"AIF ", "AIFF", "MPG3", "WAVE", "Mp3 "}
-- max_number is arbitrary, since I use the clipboard for output I don't want it too long a list
property max_number : 30
tell application "Finder"
set mylist to ""
set this_folder to choose folder with prompt ¬
"Choose a folder to list:"
set folder_items to every file of this_folder whose ¬
(file type is in extension_list)
set found_items to count of folder_items
if found_items > 0 then --- don't bother if list is empty
if found_items > max_number then
set folder_items to items 1 through max_number of folder_items
set found_items to max_number --- no need to recount, we know it's max_number
end if
repeat with mycount from 1 to found_items
set f to item mycount of folder_items as string
tell application "System Events"
try
set f to audio file f
on error
error "Not an audio file."
end try
tell (get contents of f)
set n to name of f
set t to (its duration) / (its time scale)
set hr to text 2 thru 3 of ((100 + t div hours) as string)
set min to text 2 thru 3 of ((100 + t mod hours div minutes) as string)
set sec to text 2 thru 3 of ((100 + t mod minutes div 1) as string)
set frm to text 2 thru 3 of ((100 + t mod 1 * 30) as string)
set d to ""
if (hr is not equal to "00") then
set d to hr & ":"
end if
--- use this one if you want frames displayed after a decimal point:
--- set d to d & min & ":" & sec & "." & frm
--- use this one if you want no frames displayed:
set d to d & min & ":" & sec
end tell
end tell
set mylist to mylist & mycount & tab & n & tab & d & tab & return
end repeat
set the clipboard to «class ktxt» of ((the mylist as text) ¬
as record)
else
set the clipboard to ""
end if
end tell

Jim Weisbin
human
138 5th avenue. 3rd floor, nyc, ny 10011
telephone 212 352 0211
facsimile  212 352 0210
<email@hidden>
http://www.humanworldwide.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/mailman//archives/applescript-users

This email sent to email@hidden

  • Prev by Date: Re: Get/Set text selected in a Mail.app message
  • Next by Date: create a new plist item using applescript
  • Previous by thread: Re: Durations of mp3 files?
  • Next by thread: iTunes - referring to a track in the library via its database ID
  • Index(es):
    • Date
    • Thread