Jump to content

Applescript to input image based on filename


This topic is 6167 days old. Please don't post here. Open a new topic instead.

Recommended Posts

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.

Link to comment
Share on other sites

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 ]

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This topic is 6167 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.