Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Batch Exporting Multiple Images out of Container Field

Featured Replies

  • 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!

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.

 

  • Author
  • 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

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.

  • Author
  • 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

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.

 

  • Author
  • Newbies

Yay! Thanks so much! Making a unique number from the item number did the trick! Appreciate all the help.

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.