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.

Looping script to extract container jpegs

Featured Replies

The task here is to extract thousands of jpeg files in container fields and export them to a particular folder. I'm guessing I can use the script:

Export Field Contents [; ""]

... and loop the script with variables set. The field name is Clinical::LabReport. I would like to set the to the field contents of the PatientID field, that is unique in each record. This is where I need help; defining and implementing the variables, and the script steps to loop the found set. Hope this is possible.

~Dennis

system: MacG5, FileMaker 8.5.

You can not export the Data in a Container Field in version 7 without a plugin. In v8, you can export Field Contents but it doesn't seem to save a name. However, I'm still neebee with v8, so someone else may have better advice on this.

Lee

  • Author

Thanks for the response Lee. I'm in FM 8.5, and the filename is where I am stuck. Hoping to get past it using a local variable, but don't know how.

~Dennis

Oops, I could swore that your profile said v7, sorry. It still might take a plugin to do what you want.

I haven't played with v8.5 yet, but it sounds like Export Field Content hasn't change then. Try doing a search of the Forum using [color:blue]+Export +Container +Field, as the Keywords (include the pluses as shown), with [color:blue]Fenton as the member, and you should find a a couple of Treads on and AppleScript.

HTH

Lee

You can use a variable to export a container, just like in any other export. For example, the following script exports all images in ImageField to a folder named ExportedFolder located at user's desktop (the folder needs to exist beforehand), naming them sequentially.

Show All Records

Go to Record/Request/Page [ First ]

Loop

Set Variable [ $filePath; Value:"filemac:" & Get ( DesktopPath ) & "/ExportedFolder/" & Table::SerialID & ".jpg" ]

Export Field Contents [ Table::ImageField; “$filePath” ]

Go to Record/Request/Page [ Next; Exit after last ]

End Loop

---

I'd suggest you try this with a small found set, until you get it to work.

Edited by Guest

  • Author

This script looks like it will do what I need; so I'll give it a go. Thank you so very much.

~Dennis

Hi comment,

PERFECT!

Thank you,

Lee

  • Author

Oops, hit a bump. Used this script on a small found set of records with container fields to export:

Go to Record/Request/Page [ First ]

Loop

Set Variable [ $filePath; Value:"filemac:" & Get ( DesktopPath ) & "/Docs/" & OUTSIDE ADMIN DOCS::DocsID & ".pdf" ]

Export Field Contents [ OUTSIDE ADMIN DOCS::OutsideAdminDocs; “$filePath” ]

Go to Record/Request/Page [ Next; Exit after last ]

End Loop

... and get this error when I run the script through the debugger in FileMaker 8.5 Advanced:

ERROR: "100664.2-Docs-1581.pdf" could not be created on this disk. Use a different name, make more room on the disk, unlock it or use a different disk.

The filename is legal as far as I can tell. Ran one container field with a test Export Field Contents script by itself, and it ran fine. I'd be so happy if someone has an idea to correct the local variable setting.

~Dennis

It sounds like the file name is not unique.

I got that error initially because I had selected / added the folder using that option in the Export File Contents, the path looked like [color:blue]file:../../../../../Users/leesmith/Desktop/Export/$filePath,, but your path looks right, is the folder "Doc" labeled correctly?

If you want to post a demo of your files, I'm sure we can spot the problem.

Lee

  • Author

Thank you both for trying to help me with this. The filenames are unique and the Docs folder is the same in both the script variable value and Desktop. So let me create a new database with different container contents, run an adapted script and see what happens. I will post back with the results. I am truly grateful for your assistance here.

~Dennis

It should be simple enough to insert a pause in the loop (or use the debugger) and see if a file with the problematic name already exists in the exported folder before the error occurs.

  • Author

Attached is a zipped test file that illustrates the clinic database issue that gives the script error:

"GMa_4321.jpg" could not be created on this disk. Use a different name, make more room on the disk, unlock it or use a different disk.

The error generates from this script:

Show All Records

Go to Record/Request/Page [ First ]

Loop

Set Variable [ $filePath; Value:"filemac:" & Get ( DesktopPath ) & "/Docs/" & ScriptTest:;)& ExportName ".jpg" ]

Export Field Contents [ ScriptTest::Container; “$filePath” ]

Go to Record/Request/Page [ Next; Exit after last ]

End Loop

Make yourself a "Docs" folder on your desktop. I eagerly anticipate your observations and recommendation.

~Dennis

ScriptTest.fp7.zip

Your file path is wrong (same mistake as I pointed out). it contained [color:blue]file:$filePath

It should only have [color:blue]$filePath as the output file path.

Lee

  • Author

Hello Lee,

Thank you for pointing out the error. If you would be kind enough to write the script step for me with the correct syntax, then I will be able to understand how this script is supposed to run. I sincerely want to understand this so that I might make better use of parameters and variables in future work.

Gratefully,

~Dennis

Open ScriptMaker and select the Export Field Contents step.

Click on Specify... (Specify output file).

Delete the "file:" prefix, so that the Output File Path reads as:

$filePath

instead of:

file:$filePath

Interestingly enough, the script step displays and prints the same way after the correction (a bug or a feature?). But the difference is it will work now.

  • Author

Oh YES!, it does work; on my test file and in the production environment. I'm really quite thrilled. Thank you so very much for teaching me about this. This opens up a new world for me. Wow!

~Dennis

  • 6 years later...
  • Newbies

Hi,

Very good post. I was able to follow it as far as I needed to have the pictures exported from the photo container field in my table. Upon each export I was prompted to "Save" each image, is there a script step that will "Click" the "Save" button each time, so that it's a one click script without requiring the click on "Save" button.

 

Thanks

 

entourage99

Create an account or sign in to comment

Important Information

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

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.