Scripting QuickTime

Once again, into the breach…
I just don’t seem to be getting it. I want to write a simple script to make a droplet that I can drop .mp3 files on and have QuickTime convert them to .aif files so that I can burn them to CD. Yes, I have MPecker, but Toast still wants to convert them again after MPecker has done it once. But the conversions out of QT drop right in for burning. I don’t know why. So I figured a little scripting of QT and away we go. Alas, not so…
This is from the dictionary for QT for the export command:
export: Export a movie or track to a file
export reference – the movie or track to export
to alias – the destination file
as AVI/BMP/DV stream/FLC/hinted movie/image sequence/picture/
QuickTime movie/AIFF/System 7 sound/wave/MuLaw/standard MIDI/
text file – the desired file type
[using default settings/most recent settings] – the export
settings to use
[using settings preset string] – the name of the export
settings preset to use
[considering only video/sound/text/base/streaming/MPEG/MPEG Audio/
MPEG Video/music/timecode/sprite/Flash/tween/3D/QuickTime VR/
VR panorama/VR object] – considering only media of this type
within the movie
[replacing boolean] – should the original file be deleted first?
Here is my script.
on open some_files
tell app “QuickTime Player”
activate repeat with a_file in some_files open a_file get info of a_file set the_name to name of a_file set the_name to the_name as string
export a_file to (the_name & “.aif” as string) as AIFF using most recent settings
close a_file
end repeat
end tell
end open
Clearly this is the script of an idiot. Every time I run it, AS says that it doesn’t understand the export command. Please help a poor programmer wannabe to get this thing working.
jmax

have you considered iTunes… http://www.malcolmadams.com/itunes/

: have you considered iTunes… http://www.malcolmadams.com/itunes/
Frankly, no. It has become a 'programming / scripting" thing with me to try to do as many things as possible with AS so I can learn it. It is somewhat of a twisted addiction. But I may look into it if no one is able to tell me what I am doing wrong.
Thanks
jmax

Hi Kel, thanks for this. It didn’t work, though. When it got to the line that I have put a series of X’s in front of, it says that file_ref has not been defined. I will tinker with it, but I am a little overwhelmed by the length of this script. I really did think it could be done with much less. But that is coming from a newbie with much to learn. Oh well, I will get there someday. Thanks again for a good starting point to look at.
********************************************************************************* Hi,
It has been a while since I did scripting with QT, but, if you want to try this out and look at it then here’s what I came up with:
on open file_list
tell application “QuickTime Player”
launch
end tell
tell application “Finder”
set fold_path to ¬
(make new folder at desktop ¬
with properties {name:“QT_Exported_AIFF”}) as string
end tell

repeat with file_ref in file_list

set the_name to name of (info for file_ref)
set def_tid to AppleScript’s text item delimiters
set AppleScript’s text item delimiters to {“.”}
try
set ti_list to every text item of the_name
set AppleScript’s text item delimiters to def_tid
on error err_mess
set AppleScript’s text item delimiters to def_tid
display dialog err_mess
error err_mess
end try
set new_name to (item 1 of ti_list & “.aif”)

set file_spec to file (fold_path & new_name)

tell application “QuickTime Player” XXXXXXXXX open {file_ref}
tell front movie
stop
rewind
end tell
try
if can export front movie as AIFF then
export front movie to file_spec as AIFF
else
display dialog “Can’t export " & the_name & " as AIFF.” buttons ¬
{“OK”} default button “OK”
end if
on error
try
– do nothing, can’t export for some other reason
tell application “Finder” to delete file_spec
on error
beep 3
end try
end try
close front movie saving no
end tell
end repeat
tell application “QuickTime Player” to quit
end open
There’s just a little error checking, so, you may want to add more.
gl, Kel.

: have you considered iTunes… http://www.malcolmadams.com/itunes/
Ok, I could not get a working script for QT and so have looked into itunes. It failed the test miserably. Yes, it did convert the files to .aif format. But Toast did not recognize them as being acceptable. I checked all the settings and it just wouldn’t work. Repeated attempts all failed. When I move the files to the Toast window it wants to convert them again. This is what I am trying to get around.
And iTunes will not burn CDs. At least not with my burner. There is no command of any kind in any menu or whatever to burn a CD. I have also found that if Toast does the job of converting the files it often fails to burn the CD properly. So far the only thing that has been successful is to convert with QT and then drop them directly on Toast for burning. So, you can see why I don’t want to sit there and convert them one at a time.
Any help here will be appreciated.
Thanks.

This is a quick fix. You might want to add error processing etc. – on open songList repeat with thisSong in songList tell application “QuickTime Player” stop every movie close every movie saving no activate open thisSong set songTitle to name of movie 1 set new_file to new file default name songTitle & “.aif” export track 1 to new_file as AIFF using most recent settings end tell end repeat end open --/

hmmm… weird.
–/
on open songList
repeat with thisSong in songList
tell application “QuickTime Player”
stop every movie
close every movie saving no
activate
open thisSong
set songTitle to name of movie 1
set new_file to new file default name songTitle & “.aif”
export track 1 to new_file as AIFF using most recent settings
end tell
end repeat
end open
–/

i could be off here - but for the sake of testing… try using all of your current mp3s… and convert the creators to QT… rather than trying to save them with QT.
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
on open theFolder
repeat with thisItem in theFolder
setCreator(theFolder) of me
end repeat end open
on run
tell application “Finder”
display dialog ¬
“This is a droplet. Please drop a folder of files or a folder of folders of files on me.” with icon 1 buttons {“Ok”} default button 1
end tell end run
on setCreator(theFolder)
tell application “Finder”
activate
set theseFolderItems to every item in theFolder
repeat with thisItem in theseFolderItems
if kind of thisItem is not “Folder” then
set creator type of thisItem to “TVOD”
else
my setCreator(thisItem) – recursive
end if
end repeat
end tell
end setCreator
– Script by T.J. Mahaffey – www.tjmahaffey.comtj@tjmahaffey.com
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
hope this helps… jc