Jump to content
Server Maintenance This Week. ×

Batch Exporting Multiple Images out of Container Field


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

Recommended Posts

  • Newbies

Hi,

I tried using the below script to export batch images from my container field:

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

And modified it with all my information and when I run it in my database it only exports the first picture in each container when 1. there are multiple images in each container and 2. there are multiple records within each collection. I'm trying to batch export every image in the database.

The image database is its own relational database and is a container field where multiple images can be inserted. Is there a way to modify the above script so that it picks up all the images in the database and not just the first one?

Let me know if you need anything else from me. Thank you!

Link to comment
Share on other sites

2 hours ago, adizz said:

it only exports the first picture in each container when 1. there are multiple images in each container 

Not sure what exactly you mean by that. A container field contains at most one picture. Unless you are using a repeating field, in which case you would need to nest another loop.

 

2 hours ago, adizz said:

The image database is its own relational database and is a container field where multiple images can be inserted.

Is it possible you have multiple images as individual records in a child table, and you are looping over the records of the parent table? That would indeed export only the image in the first child record of every parent in the found set. To export all images, you would need to start by Go to Related Record [ Child ; Show only related records; Match all records in the current found set  ] and do the loop from there.

 

Link to comment
Share on other sites

  • Newbies

Hi,

Thanks for the response.

I inherited this DB and kind of learning on the fly here so attached some pictures of the layout of the database as well as how the container field looks like.

Each item in a collection has multiple pictures in the image table.

Let me know if that helps clarify things and I'll give your suggestion a go right now as well.

 

Screen Shot 2020-06-10 at 8.22.43 PM.png

Screen Shot 2020-06-10 at 8.23.18 PM.png

Link to comment
Share on other sites

Context is key in FileMaker. As comment suggested, go to a layout that's based on the Images table and run your loop/export there. You can make Go to Layout the first step in your script; then Show All Records if you want to export them all; then Loop.

Link to comment
Share on other sites

  • Newbies
Thank you for your reply.

I tried your suggestions and the comments with my code below:
Go to Layout ["Images" (Images) ; Animation: None]
Show All Records
Go to Record/Request/Page [ First ]
Set Variable [ $filePath ; Value: Get ( DesktopPath ) & "exports/" ]
Loop
Set Variable [ $fileName ; Value: Images::__kft_Item & ".jpg"]
Set Variable [ $exportPath ; Value: $filePath & fileName]
Export Field Contents [ Images::Image ; "$exportPath" ; Create directories: Off]
Go to Record/Request/Page [ Next ; Exit after last: On ]
End Loop
 
This was able to export every jpeg in the Images table. The problem I ran into is that there are multiple images with the same item number. So it seems like the loop is only exporting the first one, and not all the duplicates. Is there a way to fix this so that every image is exported, even the ones with the duplicate names (though they have duplicate names, they are separate images). See photo below.

Thanks!

Screen Shot 2020-06-12 at 19_47_55-1.png

Link to comment
Share on other sites

41 minutes ago, adizz said:

The problem I ran into is that there are multiple images with the same item number. So it seems like the loop is only exporting the first one, and not all the duplicates.

I believe it is exporting all of them - but if you do not use a unique path for each image, then each export will overwrite a previous one with the same name. Why do you need to use the foreign key to Items as the file name? It seems meaningless anyway. Use something unique to each image such as the primary key field of the Images table or Get ( RecordID ) or even just a serial number.

 

Link to comment
Share on other sites

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