I am trying to make it easy to add comments to images so they can
be found easily using the spotlight search engine. None of my images
have comments yet and I have hundreds if not thousands. I am trying
to make a simple script that will search for only images that have not
had comments entered yet. Please help.
problem #1 I cannot seem to filter items by comment like you can by extention.
problem #2 I cannot get Preview to close the window, just to quit.
set this_folder to (choose folder with prompt "Pick the folder containing the images to add comments too") as string -- pick the folder
tell application "System Events" -- make sure they are images that don't have comments already
set these_files to every file of folder this_folder whose name does not start with "." and (file type is "TIFF" or file type is "JPEG" or name extension is "tiff" or name extension is "tif" or name extension is "jpeg" or name extension is "jpg") --problem #1
end tell
repeat with i from 1 to the count of these_files --line all the images up to run one after another
set thePicture to (item i of these_files as alias)
tell application "Preview"
open thePicture --open the image of the first picture in Preview
end tell
set stringToBeDisplayed to "Add your comment" -- make a window to add commments to the photo
set tempVar to display dialog stringToBeDisplayed default answer "" buttons {"Quit", "Ok"} default button "Ok"
set theButtonPressed to button returned of tempVar
if theButtonPressed is "Quit" then --if Quit is selected then quit
say "good by"
tell application "Preview"
quit
end tell
else
set commentEntered to text returned of tempVar --make the text entered the spotlight comments
tell application "Finder"
set the comment of thePicture to the commentEntered
tell application "Preview"
close front window --problem #2
end tell
end tell
end if
end repeat