Export group of Quicktime annotations in tab-delimited text file

Hello all.

I’m trying to write a script that will take the annotations from all of the Quicktime Files in a chosen folder and put them in a tab-delimited text file. I started with the pre-written “Iterate Items-Files of chosen folder” script and added what I thought would be the Quicktime specific script, but when I run it, I get the message, “can’t get alias” and then the path to the folder I’ve selected. Any ideas what’s going wrong? Here’s the script:

set this_folder to (choose folder with prompt "Pick the folder containing the files to process:") as string
tell application "System Events"
	set these_files to every file of folder this_folder
end tell
repeat with i from 1 to the count of these_files
	set this_file to (item i of these_files as alias)
	set this_info to info for this_file
	if visible of this_info is true and alias of this_info is false then
		
		-- insert actions here for: this_file
		
		tell application "QuickTime Player" to set theList to (annotation "description" of this_file) & tab & (annotation "information" of this_file) & tab & (annotation "album" of this_file) & return
		
		tell application "TextEdit"
			tell (make new document)
				set every text of it to (theList as string)
			end tell
		end tell
	end if
end repeat

As always, Thanks,

  • Bruce

Hi,

System Events’ file handling works a bit different as the Finder’s.
Your major problem is to tell QuickTime Player to read the annotations without having opened the file.
A benefit to use System Events is, it can read QuickTime files without opening QuickTime Player.
TextEdit is also not needed to create a plain text file. AppleScript will create a file with the name of the chosen folder an desktop

Note: in your script is no error handling if one of the annotations doesn’t exist.
In my script the entire file will be skipped


set this_folder to (choose folder with prompt "Pick the folder containing the files to process:")
tell application "System Events" to set these_files to every file of this_folder
set textFile to ((path to desktop as text) & name of (info for this_folder))
set theList to {}
repeat with oneFile in these_files
	try
		tell application "System Events"
			set QTfile to QuickTime file (path of oneFile)
			tell contents of QTfile
				set end of theList to (annotation "description") & tab & (annotation "information") & tab & (annotation "album")
			end tell
		end tell
	end try
end repeat
set {TID, text item delimiters} to {text item delimiters, return}
set theList to theList as text
set text item delimiters to TID
try
	set ff to open for access file textFile with write permission
	write theList to ff
	close access ff
on error
	try
		close access file textFile
	end try
end try

Thanks again for the help.

This seems to be working, except that I couldn’t find the file. I changed the file naming/placing part to make it appear as “my folder” on the desktop and that worked, except that now there is nothing in the file. I checked to make sure the Quicktime files had the proper annotations and also tried opening it in Excel in case the text was white or something. Any thoughts?

set this_folder to (choose folder with prompt "Pick the folder containing the files to process:")
tell application "System Events" to set these_files to every file of this_folder
set textFile to ((path to desktop as text) & "my folder")
set theList to {}
repeat with oneFile in these_files
	try
		tell application "System Events"
			set QTfile to QuickTime file (path of oneFile)
			tell contents of QTfile
				set theList to (annotation "description") & tab & (annotation "information") & tab & (annotation "album")
			end tell
		end tell
	end try
end repeat
set {TID, text item delimiters} to {text item delimiters, return}
set theList to theList as text
set text item delimiters to TID
try
	set ff to open for access file textFile with write permission
	write theList to ff
	close access ff
on error
	try
		close access file textFile
	end try
end try

Thanks again,

  • Bruce