Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

Posted

Hello!

Disclaimer: I have worked with Filemaker for a few years, but I only have experience constructing simple scripts. 

In the database I am working with, each of my records has an image container field where I enter .jpg files. I need to export these jpgs. Because there are thousands of records, I don't have time to export them one by one by right-clicking the container and choosing "Export Field Contents".  I need to find a way to batch export the images from this container for all records.

I found this FM forum that seemed promising: http://help.filemaker.com/app/answers/detail/a_id/5822/~/exporting-the-field-contents-of-a-container-field

And constructed the script from the instructions:

Go to Record/Request/Page [First]
Loop
   Set Variable [$filePath; Value: Get ( DesktopPath ) MyPics::Description & ".jpg"]
   Export Field Contents [MyPics::Picture; “$filePath”]  
       Go to Record/Request/Page [Next; Exit after last]
End Loop

This script "works" for me, so I must have done something right, but it only exports the image from the active record. So, either I did something wrong or misunderstood how the script works. I assumed the loop would perform the script for all records from "first" to "last" but it did not.

Is there anyone out there who perhaps knows what I am doing wrong or knows of a better script I could use to perform this seemingly straightforward operation? I would be very grateful.

Posted

This script "works" for me, so I must have done something right, but it only exports the image from the active record.

No, the script exports the images from all records of the current found set. It should start by finding the records you want to include, for example:

Go to Layout [ MyPics ]
Show All Records
Go to Record/Request/Page [First]
Loop
   Set Variable [$filePath; Value: Get ( DesktopPath ) & MyPics::Description & ".jpg"]
   Export Field Contents [MyPics::Picture; “$filePath”]  
   Go to Record/Request/Page [Next; Exit after last]
End Loop

Note also that the Description field must contain a unique value for each record, otherwise you will overwrite an already exported image with a new image having the same name.

Posted

I made your suggested changes, but I am still doing something wrong, getting the same result: only one record is exporting. There are things I don't really understand in the script and that may be contributing to why I am getting the result I am. The script as I have it with your suggestions is included in the screenshots.

I don't really understand how the Export Field Contents part of the script works. There are two parts to this, (1) "specify target field" and (2) "specify output file". I have uploaded a screenshot for each.

For "specify target field", I chose my image container ("Fotografía") with the images I want to export and left the Repetition as "1". It allows you to specify a calculation for the Repetition, however. Should I be specifying a calculation here to make it go through all the records? (I also tried changing the Repetition to the number of records I have, which did scroll through all the records to try to export something, but it gave me an error for each record saying "Container fields cannot be exported." Luckily I am testing all this on a database with only two records so it didn't take all day to click "ok" for each error message...).

For "specify output file"I assumed choosing "$Variable" here was the best option, hoping that because I had already chosen the "Set Variable" line of the script to access (1) the Image (PIARA_Analisis_Ceramica::Fotografía) and (2) the record's unique identifier (PIARA_Analisis_Ceramica::Nº de fragmento), that choosing "$Variable" for the Output location would allow the script to generate the images (from the container Fotografía) with its unique identifier (Nº de fragmento) as the filename. (As I understand it, that's what the script would ideally do, but I am inferring a lot here. Let me know if I am wrong on this and that I should expect some other output). However, again, only the image from the active record was exported, which had "$Variable" for its filename.

In the place of "$Variable" for the Output location, I have also tried entering a different filename (e.g. "Images"), with the same result (only now the one exported image was named "Images").

The final thing I don't understand is the Get ( DesktopPath ) part of the Set Variable line of the script. I imagined I was supposed to actually enter a filepath here, but I couldn't get one to work, so I left it just as shown, "Get ( DesktopPath )". I hope this was also correct.

Seriously, thank you for the time and help. I hope I was thorough in my explanation, but let me know if more information is needed.

Specify Field.png

Specify Output File.png

Posted

For "specify target field", I chose my image container ("Fotografía") with the images I want to export and left the Repetition as "1". It allows you to specify a calculation for the Repetition, however.

Assuming your container field is not a repeating field, you should leave the Repetition at its default value of 1.

 

For "specify output file"I assumed choosing "$Variable" here was the best option,

No, that makes no sense whatsoever. You need to specify the name of variable that you have set in the previous step to serve as the file's path. From your screenshot, that seems to be "$Op4_AE_Images". I am not sure why you would choose such a cryptic name, but if that's what you have, then your Specify Output File dialog should look like this:


op.thumb.png.19baac72c1ee0f6273ff982ed69

 

The final thing I don't understand is the Get ( DesktopPath ) part of the Set Variable line of the script. I imagined I was supposed to actually enter a filepath here, but I couldn't get one to work, so I left it just as shown, "Get ( DesktopPath )".

You can enter an actual filepath. Using Get ( DesktopPath ) is just a convenient way to enter the first part of the filepath dynamically, so that it will work if you run this on another system.

Posted

It worked!! You've been ver generous with your time, thank you so much. You have made this lowly phd student's life a million times better.

(For the record, I thought the variable name was going to create a folder of that name for the images to go into, which is why I named it so screwy, but now I get how the script works. And I'll play with the way I formatted "Get ( filepath )" to figure out what I was doing wrong there, so that I can dictate a specific folder I want them to go into).

I am very happy with the results and can move ahead with my project. But I will throw one final question out there if you (or anyone) has a quick solution.

The exported filename of each image is the unique identifier (for example "AE1453") followed by the .jpg's original filename (for example "IMG_2543"), so they show up like this "AE1453IMG_2534". Is there a way to add a space or a dash between these elements so that the files are more easily searchable and viewable, for example:

AE1453 IMG_2534 or 

AE1453 - IMG_2534

?

Again, thanks.

This topic is 3433 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.