Link to home
Start Free TrialLog in
Avatar of marcparillo
marcparillo

asked on

Export Images from FileMaker Pro

I need help exporting data and images from FileMaker Pro.

As far as I can tell, there doesn't seem to be a way to automatically export data from FileMaker Pro that will also copy the image from its container into a separate folder.  

Ideally, the data from each record would go into an XML file and the image from each record would be extracted and copied to a separate folder on my desktop.  So, in the end, I would have an XML file with the information and a folder with each .jpg or .bmp that was extracted from the database.

I've seen some FileMaker Pro Scripts that claim to do this, but I can't get any of them to work.  

I have FMP 11.

Any help would be greatly appreciated!

Thank you
-marc
Avatar of Tocacar
Tocacar
Flag of United States of America image

You could use the Export Field Contents script step:  http://www.filemaker.com/help/html/add_view_data.4.16.html#1028749
Avatar of marcparillo
marcparillo

ASKER

Thank you.  However, I was looking for an automated solution, in the form of a script, that could loop through hundreds of records and extract the image and other fields.  Your suggestion requires me to go through each record.
Yes, I think that's the only way you can do it I'm afraid.

A quick google of the topic turned up this though...:  http://www.entropy.ch/blog/Mac+OS+X/2006/06/03/Exporting-Images-from-FileMaker-DB-fields.html

Looks complicated, but I hope it helps.
I found a solution combing through the Internet too, but I'm not sure how it works.

Would you take a look at it?  It's a short script, attached as a PDF file.

The script appears to do what I need it to.  However, I'm not a FileMaker Pro scripter.  I'm not sure what variables I need to change to make this work for my particular database.

Thank you!


Container-Export-DT-Loop.pdf
It looks like all you need to do is make sure you have a folder on your desktop called Pictures and, within the Export Field Contents, make sure you have the correct target field (i.e., your container field) selected.

This is going to loop through all your records (which is what I originally had in mind with my first post).  I'm just pointing this out because I thought you said you didn't want to do this.  Maybe I misunderstood what you said.

Good luck.
Thank you Tocacar,

But what do you mean by "have the correct target field selected?"  Do you mean I need to put focus on the container element in the database before I run the script so that the script understands what I need to export?  

And I have a question about this specific part of the code below.  The "ContainIt::Info" and "ContainIt::Contain" appears to be variables referencing the image.   Do you know the significance of this part of the code?

... prfx & Get (DesktopPath) & "Pictures/" & ContainIt::Info
) ]
Export Field Contents [ ContainIt::Contain; “$filepath” ]

ASKER CERTIFIED SOLUTION
Avatar of Tocacar
Tocacar
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That's very helpful thank you.

It works now... I attached a code snippet for anyone in case they need it.

The thing to remember is "Pictures/" & ContainIt::Info must be a valid filename.  

The "Set Variable" function is creating the filepath variable where the image will be saved.  So, in the example, ContainIt::Info is a reference to some field in the database (a string or a number) that will become the name of your image file in the /Pictures/ folder.  

I'm making the filename some identifiable and unique field so that the right image can match to the correct record.

Hope that helps someone.




Freeze Window

Show Custom Dialog [ Title: "Export Images to Desktop"; Message: "Will export the " & Get ( FoundCount ) & " images of the found set to
a folder \"Pictures\" on your Desktop. If you do not have that folder, go create it first."; Buttons: “OK”, “Cancel” ]

If [ Get (LastMessageChoice) = 2 ]

Halt Script

End If

Go to Record/Request/Page

[ First ]

Set Error Capture [ On ]

Loop

Set Variable [ $filepath; Value:Let (
prfx = Case ( Abs ( Get (SystemPlatform)) = 1; "filemac:"; "filewin:");
prfx & Get (DesktopPath) & "Pictures/" & DatabaseName::DatabaseFieldOfYourChoice
) ]

Export Field Contents [ DatabaseName::ImageContainerName; "$filepath" ]

Exit Loop If [ Get (LastError) ¿ 0 ]

Go to Record/Request/Page

[ Next; Exit after last ]

End Loop

Go to Record/Request/Page

Open in new window

Thanks so much for your help!!