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
|