Moving files to a specified folder after export jpeg from quicktime

Hi there,

My first applescript and im stuck!

My plan i to make a script that does the following:

  • dorp a .mov on the script
  • extract 8 jpeg files
  • save all the files on a selected dir on a smb mounted share on the network
  • connect to a mysql db and put alle files in a record
  • move the original mov to the same selected dir.

So far i managed to extract the jpeg files, give them appropiated filenames, select the destination dir…but then…
i won’t copy the jpeg files to the dir i selected…why? i get an error that filder can’t get the selected file but it does exsist in the selected folder.

hopefully someone cn help me.



property default_width : 200

set theDir to choose folder with prompt "Selecteer de folder waar de bestanden geplaatst moeten worden."


tell application "QuickTime Player"
	activate
	
	try
		if not (exists movie 1) then error "No movies are open."
		
		stop every movie
		
		-- CHECK FOR THE CORRECT VERSION
		set QT_version to (QuickTime version as string)
		set player_version to (version as string)
		if (QT_version is less than "5.0") or ¬
			(player_version is less than "5.0") then
			error "This script requires QuickTime 5.0 or greater." & ¬
				return & return & ¬
				"Current QuickTime Version: " & QT_version & return & ¬
				"Current QuickTime Player Version: " & player_version
		end if
		
		-- CHECK FOR QUICKTIME PRO
		if QuickTime Pro installed is false then
			set the target_URL to "http://www.apple.com/quicktime/download/"
			display dialog "This script requires QuickTime Pro." & return & return & ¬
				"If this computer is currently connected to the Internet, " & ¬
				"click the "Upgrade" button to visit the QuickTime Website at:" & ¬
				return & return & target_URL buttons {"Upgrade", "Cancel"} default button 2
			ignoring application responses
				tell application "Finder"
					open location target_URL
				end tell
			end ignoring
			error number -128
		end if
		
		try
			--set this_name to the full text of annotation "Full Name"
			set this_name to the name of movie 1
			set bla to ((length of this_name) - 4)
			set this_name to (characters 1 thru bla of this_name) as string
			
		on error
			set this_name to bla
		end try
		
		
		
		copy the dimensions of movie 1 to {movie_width, movie_height}
		--set high quality of track "Video Track" of movie 1 to true
		--set deinterlace fields of track "Video Track" of movie 1 to true
		--set high quality of track "Video Track" of movie 1 to true
		-- Set the default width
		set requested_number to default_width
		-- Calculate the new height
		set the new_width to the requested_number div 1
		set aspect_number to (movie_height * new_width) / movie_width
		set aspect_number to round aspect_number rounding to nearest
		set the new_height to the aspect_number div 1
		-- set the dimensions of the front movie
		set the dimensions of movie 1 to {new_width, new_height}
		
		set movie_scale to the time scale of movie 1
		set eerste_stap to 2 * movie_scale --2 sec
		
		set aantal_stappen to ((duration of movie 1) - eerste_stap) / 8
		set the destination_folder to theDir
		rewind movie 1
		
		set current time of movie 1 to eerste_stap
		
		set this_file to (this_name & "-1.jpg")
		set the target_file to ((destination_folder as string) & this_file)
		set the chosen_preset to "Photo-JPEG"
		export movie 1 to target_file as picture using settings preset chosen_preset with replacing
		
		tell application "Finder"
			move target_file to disk theDir
		end tell
		
		set current time of movie 1 to eerste_stap + (1 * aantal_stappen)
		
		set this_file to (this_name & "-2.jpg")
		set the target_file to ((destination_folder as string) & this_file)
		set the chosen_preset to "Photo-JPEG"
		export movie 1 to target_file as picture using settings preset chosen_preset with replacing
		
		tell application "Finder"
			move target_file to disk theDir
		end tell
		
		set current time of movie 1 to eerste_stap + (2 * aantal_stappen)
		
		set this_file to (this_name & "-3.jpg")
		set the target_file to ((destination_folder as string) & this_file)
		set the chosen_preset to "Photo-JPEG"
		export movie 1 to target_file as picture using settings preset chosen_preset with replacing
		
		tell application "Finder"
			move target_file to disk theDir
		end tell
		
		set current time of movie 1 to eerste_stap + (3 * aantal_stappen)
		
		set this_file to (this_name & "-4.jpg")
		set the target_file to ((destination_folder as string) & this_file)
		set the chosen_preset to "Photo-JPEG"
		export movie 1 to target_file as picture using settings preset chosen_preset with replacing
		
		tell application "Finder"
			move target_file to disk theDir
		end tell
		
		set current time of movie 1 to eerste_stap + (4 * aantal_stappen)
		
		set this_file to (this_name & "-5.jpg")
		set the target_file to ((destination_folder as string) & this_file)
		set the chosen_preset to "Photo-JPEG"
		export movie 1 to target_file as picture using settings preset chosen_preset with replacing
		
		tell application "Finder"
			move target_file to disk theDir
		end tell
		
		set current time of movie 1 to eerste_stap + (5 * aantal_stappen)
		
		set this_file to (this_name & "-6.jpg")
		set the target_file to ((destination_folder as string) & this_file)
		set the chosen_preset to "Photo-JPEG"
		export movie 1 to target_file as picture using settings preset chosen_preset with replacing
		
		tell application "Finder"
			move target_file to disk theDir
		end tell
		
		set current time of movie 1 to eerste_stap + (6 * aantal_stappen)
		
		set this_file to (this_name & "-7.jpg")
		set the target_file to ((destination_folder as string) & this_file)
		set the chosen_preset to "Photo-JPEG"
		export movie 1 to target_file as picture using settings preset chosen_preset with replacing
		
		tell application "Finder"
			move target_file to disk theDir
		end tell
		
		set current time of movie 1 to eerste_stap + (7 * aantal_stappen)
		
		set this_file to (this_name & "-8.jpg")
		set the target_file to ((destination_folder as string) & this_file)
		set the chosen_preset to "Photo-JPEG"
		export movie 1 to target_file as picture using settings preset chosen_preset with replacing
		
		tell application "Finder"
			move target_file to disk theDir
		end tell
		
		
		close movie 1 saving no
		
	on error error_message number error_number
		if the error_number is not -128 then
			beep
			display dialog error_message buttons {"Cancel"} default button 1
		end if
	end try
end tell

I altered the script a little bit. I place all the files into a new folder on the desktop, afterwards i want to move the complete folder to the selected folder on the smb share…but…sort of the same error, it won’t move the folder!



property default_width : 200
set theDefaultDir to path to desktop folder as alias

set mountedDisks to list disks
if mountedDisks does not contain "Masters2006" then
	tell (application "Finder")
		try
			mount volume "smb://VIDEO/Masters2006/" as user name "user" with password "password"
		on error
			display dialog "Er is iets misgegaan met het mounten van de netwerkschijf." & return & return & "De server kan tijdelijk offline zijn." & return & return & "Neem contact op met Niek, intern 220)." buttons {"Okay"} default button 1
		end try
	end tell
	
end if

tell application "Finder"
	if exists folder "movpicts" of theDefaultDir then
		delete folder "movpicts" of theDefaultDir -- moves to trash
	end if
	set TheImagetank to (make new folder at theDefaultDir with properties {name:"movpicts"})
end tell




set theDir to choose folder with prompt "Selecteer de folder waar de bestanden geplaatst moeten worden."


tell application "QuickTime Player"
	activate
	
	try
		if not (exists movie 1) then error "No movies are open."
		
		stop every movie
		
		-- CHECK FOR THE CORRECT VERSION
		set QT_version to (QuickTime version as string)
		set player_version to (version as string)
		if (QT_version is less than "5.0") or ¬
			(player_version is less than "5.0") then
			error "This script requires QuickTime 5.0 or greater." & ¬
				return & return & ¬
				"Current QuickTime Version: " & QT_version & return & ¬
				"Current QuickTime Player Version: " & player_version
		end if
		
		-- CHECK FOR QUICKTIME PRO
		if QuickTime Pro installed is false then
			set the target_URL to "http://www.apple.com/quicktime/download/"
			display dialog "This script requires QuickTime Pro." & return & return & ¬
				"If this computer is currently connected to the Internet, " & ¬
				"click the "Upgrade" button to visit the QuickTime Website at:" & ¬
				return & return & target_URL buttons {"Upgrade", "Cancel"} default button 2
			ignoring application responses
				tell application "Finder"
					open location target_URL
				end tell
			end ignoring
			error number -128
		end if
		
		try
			--set this_name to the full text of annotation "Full Name"
			set this_name to the name of movie 1
			set bla to ((length of this_name) - 4)
			set this_name to (characters 1 thru bla of this_name) as string
			
		on error
			set this_name to bla
		end try
		
		
		
		copy the dimensions of movie 1 to {movie_width, movie_height}
		--set high quality of track "Video Track" of movie 1 to true
		--set deinterlace fields of track "Video Track" of movie 1 to true
		--set high quality of track "Video Track" of movie 1 to true
		-- Set the default width
		set requested_number to default_width
		-- Calculate the new height
		set the new_width to the requested_number div 1
		set aspect_number to (movie_height * new_width) / movie_width
		set aspect_number to round aspect_number rounding to nearest
		set the new_height to the aspect_number div 1
		-- set the dimensions of the front movie
		set the dimensions of movie 1 to {new_width, new_height}
		
		set movie_scale to the time scale of movie 1
		set eerste_stap to 2 * movie_scale --2 sec
		
		set aantal_stappen to ((duration of movie 1) - eerste_stap) / 8
		--set the destination_folder to theDir
		rewind movie 1
		
		set current time of movie 1 to eerste_stap
		
		set this_file to (this_name & "-1.jpg")
		set the target_file to ((TheImagetank as string) & this_file)
		set the chosen_preset to "Photo-JPEG"
		export movie 1 to target_file as picture using settings preset chosen_preset with replacing
		
		set current time of movie 1 to eerste_stap + (1 * aantal_stappen)
		
		set this_file to (this_name & "-2.jpg")
		set the target_file to ((TheImagetank as string) & this_file)
		set the chosen_preset to "Photo-JPEG"
		export movie 1 to target_file as picture using settings preset chosen_preset with replacing
		
		
		set current time of movie 1 to eerste_stap + (2 * aantal_stappen)
		
		set this_file to (this_name & "-3.jpg")
		set the target_file to ((TheImagetank as string) & this_file)
		set the chosen_preset to "Photo-JPEG"
		export movie 1 to target_file as picture using settings preset chosen_preset with replacing
		
		set current time of movie 1 to eerste_stap + (3 * aantal_stappen)
		
		set this_file to (this_name & "-4.jpg")
		set the target_file to ((TheImagetank as string) & this_file)
		set the chosen_preset to "Photo-JPEG"
		export movie 1 to target_file as picture using settings preset chosen_preset with replacing
		
		
		set current time of movie 1 to eerste_stap + (4 * aantal_stappen)
		
		set this_file to (this_name & "-5.jpg")
		set the target_file to ((TheImagetank as string) & this_file)
		set the chosen_preset to "Photo-JPEG"
		export movie 1 to target_file as picture using settings preset chosen_preset with replacing
		
		
		set current time of movie 1 to eerste_stap + (5 * aantal_stappen)
		
		set this_file to (this_name & "-6.jpg")
		set the target_file to ((TheImagetank as string) & this_file)
		set the chosen_preset to "Photo-JPEG"
		export movie 1 to target_file as picture using settings preset chosen_preset with replacing
		
		
		set current time of movie 1 to eerste_stap + (6 * aantal_stappen)
		
		set this_file to (this_name & "-7.jpg")
		set the target_file to ((TheImagetank as string) & this_file)
		set the chosen_preset to "Photo-JPEG"
		export movie 1 to target_file as picture using settings preset chosen_preset with replacing
		
		set current time of movie 1 to eerste_stap + (7 * aantal_stappen)
		
		set this_file to (this_name & "-8.jpg")
		set the target_file to ((TheImagetank as string) & this_file)
		set the chosen_preset to "Photo-JPEG"
		export movie 1 to target_file as picture using settings preset chosen_preset with replacing
		
		close movie 1 saving no
		
		tell application "Finder"
			move folder TheImagetank to folder theDir
		end tell
		
	on error error_message number error_number
		if the error_number is not -128 then
			beep
			display dialog error_message buttons {"Cancel"} default button 1
		end if
	end try
end tell

pfff,

set TheImagetank to (make new folder at theDefaultDir with properties {name:"movpicts"}) as alias

…thats it…