Noobie needs help with quicktime and applescript

Hi, a newbie here,

I’m looking for a simple droplet that will batch export Quicktime movies using it’s current settings to a specified folder.

Many thanx in advance.


Hi Stan,

Here’s an example of exporting movies to some export type using the current settings which is default:

property old_ext : ".mov"
property new_ext : ".aif"
using terms from application "QuickTime Player"
	property export_type : AIFF
end using terms from
-- get the folder with movies
set f to choose folder
-- get export folder
set e to (path to desktop as string) & "Exports:"
-- get a list of files
-- assumes every file is a movie
tell application "Finder"
		set ms to every file of f as alias list
		-- if there is only one file that matches the criteria, then error
	on error -- get an alias reference to the first file and coerce to list
		set ms to ((first file of f) as alias) as list
	end try
	-- at this point you ms is a list of alias references to the files
	-- you want alias references for use outside the Finder
	-- some apps can't handle Finder references
end tell
-- QuickTime opens the files and exports to file specifications
-- a file specification is a reference to items that may not exist
-- you must create your file specifications
-- here we will use the name of the original file and export it
-- first repeat through the list
repeat with this_file in ms
	set n to name of (info for this_file)
	if n ends with old_ext then
		-- get name without extension
		set l to length of old_ext
		set n to text 1 thru (l - 1) of n
	end if
	-- add the new extesion
	set n to n & new_ext
	-- at this point, you have the new name
	-- create a file specification at the Export folder
	set fs to (e & n) -- rem: e=export folder
	tell application "QuickTime Player"
		open this_file
		tell front movie
			if can export as export_type then
				export to fs as export_type
			end if
		end tell
	end tell
end repeat

It has been a while since I scripted QuickTime and pumped this out, but if you have any questions write back. I’m beginning to think that I’m invisible.

Edited: and BTW, before you create droplets, it’s a good idea to make sure your script works. After you are sure it works, then you wrap the script in an open handler and test it again and again adding error handling.

on open
–the script goes here
end open