Here it is. Maybe I screwed it up. I have also tried "using most recent settings" with similar results.
-- the list of file types which will be processed
-- eg: {"PICT", "JPEG", "GIFf", "TIFF"}
property type_list : {"MooV"}
-- since file types are optional in Mac OS X,
-- check the name extension if there is no file type
-- NOTE: do not use periods (.) with the items in the name extensions list
-- eg: {"txt", "text", "jpg", "jpeg"}, NOT: {".txt", ".text", ".jpg", ".jpeg"}
property extension_list : {"wav"}
global target_folder, temp_folder
on run
display dialog "Convert to QuickTime Movie" & return & return & ¬
"This script will convert dragged-on movie files to QuickTime movies." buttons {"OK"} default button 1
-- ENABLE THESE LINES FOR TESTING
--set these_items to (choose file) as list
--open these_items
end run
-- This droplet processes both files or folders of files dropped onto the applet
on open these_items
-- this routine uses the gestaltVersion_info() sub-routine
copy my gestaltVersion_info("qtim", 8) to {QT_version, QT_string}
if the QT_version is less than "0502" then
display dialog "This script requires QuickTime 5.0.2 or higher." & ¬
return & return & "The currently installed version is: " & ¬
QT_string buttons {"Cancel"} default button 1
end if
-- create a unique temp folder
repeat
set this_name to (random number from 100000 to 999999) as string
tell application "Finder"
if not (exists folder this_name of the desktop) then
set the temp_folder to (make new folder at desktop with properties {name:this_name}) as alias
exit repeat
end if
end tell
end repeat
--set the target_folder to choose folder with prompt "Destination folder for the converted files:"
repeat with i from 1 to the count of these_items
set this_item to (item i of these_items)
set the item_info to info for this_item
if folder of the item_info is true then
process_folder(this_item)
else if (alias of the item_info is false) and ¬
((the file type of the item_info is in the type_list) or ¬
the name extension of the item_info is in the extension_list) then
process_item(this_item)
end if
end repeat
-- quit QuickTime
tell application "QuickTime Player"
quit
end tell
-- delete the temp folder
-- tell application "Finder"
-- delete temp_folder
-- empty trash
--end tell
beep
end open
-- this sub-routine processes folders
on process_folder(this_folder)
set these_items to list folder this_folder without invisibles
repeat with i from 1 to the count of these_items
set this_item to alias ((this_folder as text) & (item i of these_items))
set the item_info to info for this_item
if folder of the item_info is true then
process_folder(this_item)
else if (alias of the item_info is false) and ¬
((the file type of the item_info is in the type_list) or ¬
the name extension of the item_info is in the extension_list) then
process_item(this_item)
end if
end repeat
end process_folder
-- this sub-routine processes files
on process_item(this_item)
-- NOTE that the variable this_item is a file reference in alias format
-- FILE PROCESSING STATEMENTS GOES HERE
with timeout of 3600 seconds -- one hour per movie time limit
tell application "QuickTime Player"
launch -- bypasses promo movie
activate
my toggle_suppress(true)
try
stop every movie
close every movie saving no
open this_item
if saveable of movie 1 is false then
error "This movie has previously been set so that it cannot be copied, edited, or saved."
end if
set the original_file to the original file of movie 1
tell application "Finder"
set the file_name to the name of the this_item
set the target_folder to the container of the this_item
if exists file file_name of the temp_folder then ¬
delete file file_name of the temp_folder
set the root_name to (text 1 thru (offset of "." in file_name) of file_name)
set the temp_file to ((temp_folder as text) & root_name & "mov")
set the new_file to ((temp_folder as text) & root_name & "m4a")
end tell
if (can export movie 1 as QuickTime movie) is true then
-- export the movie as QuickTime Movie
export movie 1 to file temp_file as QuickTime movie using settings alias "PowerBook:AAC_VBR_192.set"
-- close the source movie
close movie 1 saving no
-- open Quicktime moive
open temp_file
-- export as mp4 file (change container format)
export movie 1 to file new_file as MPEG4 using settings alias "PowerBook:MP4_passthrough.set"
-- close the final product
close movie 1 saving no
else
error "This movie cannot be exported as a QuickTime Movie."
end if
tell application "Finder"
move file new_file to the target_folder with replacing
end tell
my toggle_suppress(false)
on error error_msg
my toggle_suppress(false)
display dialog error_msg buttons {"Stop", "Continue"} default button 2
set the button_pressed to the button returned of the result
close movie 1 saving no
if the button_pressed is "Stop" then error number -128
end try
end tell
end timeout
end process_item
on toggle_suppress(status_flag)
tell application "QuickTime Player"
set ignore auto play to the status_flag
set ignore auto present to the status_flag
end tell
end toggle_suppress
on gestaltVersion_info(gestalt_code, string_length)
try
tell application "Finder" to ¬
copy my NumToHex((system attribute gestalt_code), ¬
string_length) to {a, b, c, d}
set the numeric_version to {a, b, c, d} as string
if a is "0" then set a to ""
set the version_string to (a & b & "." & c & "." & d) as string
return {numeric_version, version_string}
on error
return {"", "unknown"}
end try
end gestaltVersion_info
on NumToHex(hexData, stringLength)
set hexString to {}
repeat with i from stringLength to 1 by -1
set hexString to ((hexData mod 16) as string) & hexString
set hexData to hexData div 16
end repeat
return (hexString as string)
end NumToHex