August 1, 200718 yr Hi, I have a folder full of about 1000 cover images for films that is left over form a previous Access database. The images are all named according to a catalog number (that is how they were displayed in Access), which is the same in my new FMP database. Being wholly inept when it comes to Applescript, how might I go about writing a script that would import the images to container fields in their respective records in FMP.
August 1, 200718 yr I dont think you would necessarily need applescript for this. If you have a field that identifies which file that it is associated with by catalog number, then you could set a dynamic path and loop through the records. For example, assuming that the images are in the same folder, Set Variable [ $path; Value: "imagemac:/MacVolume/images/" & catalognumber_field ] Set Field [ ImgContainer; $path ]
August 1, 200718 yr Author That seems to be working pretty good, with the exception that not every record has a corresponding image. So what I need is a way to test that there is actually a file before it performs the import. Otherwise I'd have to sit there and keep pressing "ok, continue" for each error message when it doesn't find the image in the $path variable. I know there is a script step to validate that a field is not empty, etc, but is there some way to validate that a file is there or not? Or can I just build in a step to ignore errors?
August 1, 200718 yr To get rid of those error popups, you can Set Error Capture [On]. Another method would be to have a related table to store all the images in it and import all the images into a container field in it. You also need a field to parse out the catalognumber from the path of the imported image. Then you can create a relationship between the two tables keyed on the catalognumber fields. Also, Fenton posted a applescript on how to check for a file existing here. Applescript to Check File
Create an account or sign in to comment