finder iteration & QT export

hi guys

i have an odd task to achieve, and i think the key to doing it easily is AppleScript. i’m proficient in other languages, but AS is completely foreign to me, so i was hoping for some help.

what i’d like to do is:

  1. open a quicktime movie, a.mov
  2. export that quicktime movie using most recent settings to b.mov (i’ve got this part worked out already)
  3. open b.mov
  4. repeat steps 2 & 3 a couple of hundred times.

i don’t want to end up with 200 copies of the movie, just one movie that’s been recompresed 200 times. so this probably involves opening b.mov, exporting to c.mov, deleting b.mov, renaming c.mov to b.mov, repeating.

as i said, i can do the QT export bit, it’s just the iteration and manipulation of files through Finder that i’m unsure of.

all help is MUCH appreciated. thanks.

See if this works.

Regards,

Craig


property fileToOpen : (path to desktop as Unicode text) & "b0.mov"

repeat with i from 1 to 2  -- Change this to the higher number after you have tested
	
	set outputName to "b" & i & ".mov" as string
	set outputPath to (path to desktop as string) & outputName
	
	set prevMovie to "b" & (i - 1) & ".mov" as string
	set previousMoviePath to (path to desktop as string) & prevMovie
	
	tell application "QuickTime Player"
		open fileToOpen
		export document 1 to file outputPath as QuickTime movie
		close document 1
	end tell
	
	tell application "Finder"
		delete previousMoviePath
	end tell
	
	set fileToOpen to outputPath
	
end repeat