Export Images from FileMaker Pro

marcparillo
marcparillo used Ask the Experts™
on
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
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

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

Author

Commented:
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.

Commented:
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.
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Author

Commented:
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

Commented:
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.

Author

Commented:
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” ]

Commented:
Hi Marc

Q1:  Correct, double click the export field contents script step and click 'select target field', then pick the name of your container field from the list

Q2:  ContainIt::Info is the name of the container field in the script example - replace this with the name of your container field (make sure you enter it EXACTLY, with no errors).  I missed that it appeared in that bit when I had my first quick look, so as well as putting your container field's name in the Export Field Contents script step, make sure you put it in "... prfx & Get (DesktopPath) & "Pictures/" & ContainIt::Info" (in place of ContainIt::Info) as well.



Author

Commented:
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

Author

Commented:
Thanks so much for your help!!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial