Quicktime & Applescript...

Hey folks -

I’ve been browsing the boards for a while and found most of the answers to my questions. You all are great. I’ve run into one little problem, and perhaps someone could help. I’m new to creating applescripts - this is my first one that serves as real purpose. I’m basically trying to batch add a header to over 500 DV files and then export the new files as DV streams. I’ve got this applescript, which works well on my machine:

 tell application "Finder"
	tell folder "ajay" of folder "Desktop" of folder "apillar" of folder "Users" of startup disk
		set file_list to name of every item
	end tell
end tell

repeat with i from 1 to count (file_list)
	set the_name to item i of file_list
	set the_file to ("Zaphod:users:apillar:desktop:ajay:" & the_name)
	set the_new to ("Zaphod:users:apillar:desktop:ajay2:" & the_name & ".dv")
	tell application "QuickTime Player"
		activate
		open file the_file
		tell movie 1
			select none
			rewind
			paste
			select none
			rewind
			select at 0 to 0
		end tell
		if (can export movie 1 as DV stream) is true then
			tell movie 1
				export to the_new as DV stream using most recent settings
			end tell
		end if
		tell movie 1 to close
	end tell
end repeat 

i’m trying to streamline it a bit to work on other machines, so I tried to have applescript ask for folders to look in and save to… but its not working. i’ve attached that attempt below, as well. thanks in advance for any help - much appreciated. And also, kudos to the original author of this script - i only modified it a bit but found it on this board… much appreciated.

set conversion_folder to choose folder with prompt "Choose a folder which contains files you wish to modify"
set new_folder to choose folder with prompt "Choose a folder for modified files"

tell application "Finder"
	tell conversion_folder
		set file_list to name of every item
	end tell
end tell

repeat with i from 1 to count (file_list)
	set the_name to item i of file_list
	set the_file to (conversion_folder & the_name)
	set the_new to (new_folder & the_name & ".dv")
	tell application "QuickTime Player"
		activate
		open file the_file
		tell movie 1
			select none
			rewind
			paste
			select none
			rewind
			select at 0 to 0
		end tell
		if (can export movie 1 as DV stream) is true then
			tell movie 1
				export to the_new as DV stream using most recent settings
			end tell
		end if
		tell movie 1 to close
	end tell
end repeat

Hi ajaypillarisetti,

When you concatenate strings the first item needs to be a string. If the first item is a reference, then it errors. Add ‘as string’ to the end of the references:

set conversion_folder to (choose folder with prompt “Choose a folder which contains files you wish to modify”) as string
set new_folder to (choose folder with prompt “Choose a folder for modified files”) as string

I didn’t look at the rest of your script, but this is a common mistake for new scripters.

gl,

thanks! worked like a charm - much appreciated.