• 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
Question regarding audio file type "protected mpeg-4" and mp3's
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Question regarding audio file type "protected mpeg-4" and mp3's


  • Subject: Question regarding audio file type "protected mpeg-4" and mp3's
  • From: Jim Weisbin <email@hidden>
  • Date: Sat, 9 Sep 2006 11:00:04 -0400

I wrote a script which opens a folder of audio files, opens each one in Quicktime, gets the running time of each, and then copies all of that information to the clipboard. After reading Matt Neuberg's excellent book, I found that I could do the same thing with System Events, without having to open each file in QT. The following scripts works great in most cases, but fails in a few. By the way, I limit the number of items processed to max_number for internal reasons.

- Certain mp3 files fail to be detected even though they have the correct type and creator codes and full read/write access. I can't figure out why.

- If I add the protected mpeg-4 type "M4P " to the extension list, those types are still not detected. Anyone know why?

- Why is it that one can say "set f to audio file f", but cannot say, for example "set f to every audio file of this folder"?

property extension_list : {"AIFF", "MPG3", "WAVE", "Mp3 "}
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 30 of folder_items
set found_items to 30 --- no need to recount, we know it's 30
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:

This email sent to email@hidden

  • Prev by Date: Re: How to compile script in OSX
  • Next by Date: How do I loop through Indesign Button behaviors?
  • Previous by thread: [ANN] MBS Plug-in For Filemaker
  • Next by thread: OSA script error
  • Index(es):
    • Date
    • Thread