Applescript and Quicktime X (10.6)

Hi All,
I have had a helpful script that accesses Quicktime in 10.5 and copies and pastes videos into the same file. With 10.6, Quicktime no longer is able to recognize this. I checked the Dictionary, but it didn’t seem to help. I would greatly appreciate your help. Thanks so much.

original code (10.5)


tell application "QuickTime Player"
				if i is equal to 1 then
					make new document
				end if
				open this_item
				tell document 1
					rewind
					select all
					copy
					select none
				end tell
				close document 1 saving no
				tell document 1
					add
					select none
				end tell
			end tell
tell application "QuickTime Player"
			if exists window 2 then
				close window 2
			end if
			set filename to (path to desktop folder as string) & legalName & "1" & ".mov"
			set newfilename to (path to desktop folder as string) & legalName & ".mov"
			set dimensions of document 1 to {320, 180}
			resize document 1 by 100
			save self contained document 1 in newfilename
			close window 1
			quit
		end tell


This is the way it is translated with 10.6


tell application "QuickTime Player"
				if i is equal to 1 then
					make new document
				end if
				open this_item
				tell document 1
					«event MVWRrewi»
					«event MVWRslca»
					«event misccopy»
					«event MVWRslcn»
				end tell
				close document 1 saving no
				tell document 1
					«event MVWRpadd»
					«event MVWRslcn»
				end tell
			end tell
		end repeat
		
		tell application "QuickTime Player"
			if exists window 2 then
				close window 2
			end if
			set filename to (path to desktop folder as string) & legalName & "1" & ".mov"
			set newfilename to (path to desktop folder as string) & legalName & ".mov"
			set «class pdim» of document 1 to {320, 180}
			«event MVWRscal» document 1 given «class trby»:100
			«event MVWRsvsc» document 1 given «class kfil»:newfilename
			close window 1
			quit
		end tell


Quicktime X is not very scriptable. I still use Quicktime 7 on Snow Leopard.

Hi Craig,

Thank you so much for your insight. I did this and ran my script again and came up with this message. “QuickTime Player 7 got an error: Can’t get document 1. Invalid index.”

The script below errs at the notes I have placed. It also then opens Adobe Soundbooth.


tell application "QuickTime Player 7"
				if i is equal to 1 then
					make new document
				end if
				open this_item
				tell document 1
					rewind
					select all
					copy
					select none
				end tell
				close document 1 saving no
				tell document 1
					add --[b]this is where the error occurs.[/b]
					select none
				end tell
			end tell

Thanks so much!

Try paste instead of add and see if that works.

Hi Craig,

I seem to get the same issue with the paste command. It strangely opens Adobe Soundbooth after the error occurs. Thanks so much for taking the time to help you with this. The error remains the same. Basically, it is a script that takes alot of QT movies in a folder and makes them into one big QT movie.
Thanks again.

Boyd

Try this. I found it in my script archives and it is working. I just tested it with 4 mov files.


set theCount to 1
set theFolder to choose folder with prompt "Choose folder with Audio files you want to join together."
tell application "Finder"
	set theFiles to every file of folder theFolder
	set totalFiles to (count the theFiles)
	repeat with i from 1 to totalFiles --to 1 by -1
		set thisfile to item i of theFiles as alias
		
		--QT Pro
		my mergeFilesUsingQT(thisfile, theCount, totalFiles)
		
		set theCount to theCount + 1
	end repeat
	
end tell

on mergeFilesUsingQT(thisfile, theCount, totalFiles)
	tell application "QuickTime Player 7"
		activate
		--the first file only gets copied
		if theCount = 1 then
			open thisfile
			delay 0.5
			tell document 1
				select all
				copy
			end tell
			close document 1 saving no
		else
			--these files get the previous file added to it and
			--then it is copied to be added to the next file
			open thisfile
			delay 1
			tell document 1
				set x to get duration
				set current time to x
				paste
				select all
				copy
			end tell
			
			if theCount = totalFiles then
			else
				close document 1 saving no
			end if
		end if
	end tell
end mergeFilesUsingQT