I’m writing a script to solve a perennial problem for us - we have lots of people cropping images in Photoshop for Catalogs in Portfolio 6.1. Some of these people are not very good at cropping, and so frequently we get pictures with white bars running across the bottom or other hideous mistakes. So, I wrote this script to search a folder for jpegs with these white bars and put them into a list. The script should now open a portfolio catalog (which contains all the files in that folder), make a new gallery, and copy just those records with the bad cropping into the new gallery. This, surprisingly, is where I hit the snag. (I actually thought the first part would be hard and this part would be easy, but boy was I wrong!)
Here’s the pertinent part of the script:
to makegalleryofbadcrops()
set thisCatalog to choose file with prompt "What catalog contains the originals of these pictures?" of type "DBSE"
tell application "Extensis Portfolio 6.1"
activate
open thisCatalog
new gallery
save front gallery using name "fgal"
search
new gallery
save front gallery using name "recrop"
repeat with thisFile in bad_crop_list
search records of gallery "fgal" for "Filename" & tab & "contains" & tab & thisFile in all records
gallery copy records of gallery "fgal" to gallery "recrop"
end repeat
close gallery "recrop" saving yes
close gallery "fgal" saving no
delete gallery "fgal"
end tell
end makegalleryofbadcrops
So fgal is a gallery which contains all records in the catalog, and recrop is a gallery which should eventually contain everything in bad_crop_list. bad_crop_list is a property of the script with a value that looks like:
property bad_crop_list : {“ms06.jpg”, “ym03.jpg”}
bad_crop_list could potentially hold as many as 500+ items depending on how big the catalog is and how badly the cropper did their job.
First of all - HOW do I tell Portfolio to bring a particular gallery to the front? If I could do this I could save myself so many headaches with creating new galleries, saving them, and deleting them. Otherwise, how do I get Portfolio to save a gallery that’s been changed and close it, or not save a gallery, close it, and delete it? It seems I can’t get Portfolio to do anything but create or open a gallery, and that’s just not enough to be considered a scriptable application.
Second, and more important - WHY doesn’t the gallery copy command work here? Every time it gets an error that the record doesn’t understand the copy command - JUST AFTER it copies the record anyway! So, in essence, it copies the record, and then it gives an error that it can’t copy the record!? So, I thought:
try
gallery copy...
end try
But that doesn’t work, because the records copy over each other. Instead of just adding the record to the gallery, it replaces the record in the gallery.
If I can get this working, I will save myself hours upon hours of hunting through folders trying to find far-flung images. Please, oh please, someone out there know what I’m talking about! Thanks!