Saturday, July 4, 2020

#1 2002-03-29 07:06:33 am

Jmax
Member
Registered: 2002-11-20
Posts: 35

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

Offline

 

#2 2002-03-29 09:04:43 am

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

Re: Scripting QuickTime

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


One mans trash is another mans treasure

Offline

 

#3 2002-03-29 09:58:59 am

Jmax
Member
Registered: 2002-11-20
Posts: 35

Re: Scripting QuickTime

: 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

Offline

 

#4 2002-03-29 01:37:38 am

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

Re: Scripting QuickTime

: 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
well... i don't have much time to help now... open an example file (mp3) in quicktime run this script and it should export to AIFF for you no problem...
if you need help opening and batching let me know...
good luck. jc
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
tell application "QuickTime Player"
activate
set the new_file to ¬
choose file name with prompt "Give me a name and a place to live:"
export track 1 to new_file as AIFF using default settings
end tell
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::


One mans trash is another mans treasure


Filed under: QuickTime

Offline

 

#5 2002-03-29 01:42:53 am

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

Re: Scripting QuickTime

: It is somewhat of a twisted addiction.
this i understand... but as i recall... exporting from quicktime won't let you do anything else while exporting. so if you are planning to batch a whole album you might need to leave your machine alone for a bit... hardly a good thing for an addict. itunes will allow you to get your fix as well a perform your desired task. anyway... its your habit -- enjoy.
jc


One mans trash is another mans treasure

Offline

 

#6 2002-03-29 03:14:27 am

kel
Member
Registered: 2002-11-20
Posts: 2031

Re: Scripting QuickTime

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:
 
 

Applescript:

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"
   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.


Kel


Filed under: QuickTime, Finder

Offline

 

#7 2002-03-30 02:24:57 am

Jmax
Member
Registered: 2002-11-20
Posts: 35

Re: Scripting QuickTime

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.


Filed under: QuickTime, Finder

Offline

 

#8 2002-04-04 06:23:46 am

Jmax
Member
Registered: 2002-11-20
Posts: 35

Re: Scripting QuickTime

: 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.

Offline

 

#9 2002-04-20 03:40:13 am

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

Re: Scripting QuickTime

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 --/


One mans trash is another mans treasure


Filed under: QuickTime

Offline

 

#10 2002-04-20 03:50:40 am

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

Re: Scripting QuickTime

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
--/


One mans trash is another mans treasure


Filed under: QuickTime

Offline

 

#11 2002-04-29 07:30:05 am

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

Re: Scripting QuickTime

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.com -- tj@tjmahaffey.com
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
hope this helps... jc


One mans trash is another mans treasure


Filed under: Finder

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)