Usually this script works, and its great when it does work. Sometimes it doesn’t work, and the following message pops up:
“The variable MyImage is not defined”
-
Why does this happen sporadically?
-
I’m trying to get a creation date out of Image Events, but that isn’t working either. Could anyone help?
–Herbert Ripka
Greendale, WI
The following was (99%) written by Jerome on Nov. 1, 2005
http://bbs.applescript.net/viewtopic.php?id=14783
set MyImage to ""
to MakeList(ProcessFolder)
tell application "Finder"
set filelist to (files of entire contents of alias ProcessFolder whose file type is "PDF" or name extension is "pdf" as list)
return filelist
end tell
end MakeList
to GetDimensions(TheFile)
tell application "Image Events"
set MyImage to open alias TheFile
set MyResolution to resolution of MyImage
set MyDimension to dimensions of MyImage
set MyColorspace to color space of MyImage
set InfoList to name of MyImage & " " & MyResolution & " " & MyColorspace & " " & (item 1 of MyDimension) / (item 1 of MyResolution) & " " & (item 2 of MyDimension) / (item 2 of MyResolution) & return
close MyImage
end tell
return InfoList
end GetDimensions
set ProcessFolder to (choose folder) as string
set filelist to MakeList(ProcessFolder)
set MyPath to ((path to desktop folder) as string)
set logfile to MyPath & "Image_Log.txt"
open for access file logfile
close access file logfile
set MyList to ""
repeat with AnItem in filelist as list
set MyList to MyList & (GetDimensions(AnItem as string))
end repeat
open for access file logfile with write permission
write MyList to file logfile
close access file logfile