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.

Rename images on export script trouble.

Featured Replies

Hi!

 

I multiple records with multiple images (number varies). I am trying to write a script that will rename the exported images to another field's contents and then append the new file name with _1 _2... for each image attached to that particular record.

For example:

1_1

1_2

1_3

2_1

2_2

3_1

 

This is what I have so far. It is working, but it is only grabbing one image per record and skipping the others. Returning only 1_1, 2_1, 3_1 ...  Any ideas?

 

Go to Record/Request/Page [First]

Loop
Set Variable [ $filePath; Value:Get ( DesktopPath ) & "/ExportFolder/" & Table:Field Name &  "_"  & List ( 1 ; 10 ) ]

Export Field Contents [ Images::Image; "$filePath" ]

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

End Loop

 

Any help would truly be appreciated!   :)

Solved by comment

Go to solution
I multiple records with multiple images

 

Where exactly are the multiple images? Are they individual records in a related Images table (as would seem from your description)?

  • Author

Exactly.

  • Solution

But you are looping in the "main" table and your loop has only one Export Field Contents step - so you are only exporting the first related image. Also, the expression List ( 1 ; 10 )makes very little sense here.

Try something like this (untested):

Go to Record/Request/Page [First]
Set Variable [ $filePath; Value:Get ( DesktopPath ) & "ExportFolder" ]
Loop
    Go to Related Record [ Images; Show related only ]
    Loop
        Set Variable [ $fileName; Value:ParentTable:Field Name & "_" & Get ( RecordNumber ) ]
        Export Field Contents [ Images::Image; "$filePath/$fileName" ]
        Go to Record/Request/Page [ Next; Exit after last ]
    End Loop
    Go to Layout [ "ParentTable" ]
    Go to Record/Request/Page [ Next; Exit after last ]
End Loop
  • Author

Okay, now I am returning:

 

1_1

1_2

1_3

2_4

3_5

 

Is there a way to make the script start over with _1 for each record?

 

Thanks so much!

Is there a way to make the script start over with _1 for each record?

 

Well it should do that, so something must have gone wrong. Are you sure your GTRR step is set to "Show only related records; Match current record only"?

  • Author

Awesome!! That was the problem. Also, apparently I need to run the script from the parent table for it to work properly.

Thanks again.

You could export from the Images table, too - but then you'd need a summary field with restart in order to number the files.

 

 

---

 

.... or (I meant to add before I was disturbed) a counter $variable that would reset itself back to 1 when the ParentID value changed.

Edited by comment

  • Author

Thanks!

  • Author

I have multiple images stored as individual records in a related table. Each image is stored as a path in a container field.

 

My question is:

Do I need to re-import the container contents every time the image is modified/edited (also if the image were to be moved and then put back)? Seems like the field contents should update automatically via the path.

 

Am I missing something?

 

Thank you!

I have merged your two topics.

 

Please do not create multiple topics on the same need.

 

If you have any questions about this action, please contact me by Private Message.

  • Author

Sorry, I did not interpret them as the same need.

Seems like the field contents should update automatically via the path.

 

 I believe  so. Do you experience anything to suggest otherwise?

  • Author

No, my mistake.

Thank you.

  • Author

Okay this worked perfectly at home, but when I tried to implement this at work on the host; the files are exporting into the Filemaker Pro folder instead of into the desktop folder. Don't understand why it would be working any differently.

 

It is a shared database and I am installing the script on the server running FM 11 pro.

I believe there are some limitations when using the Export Records step in a server-side script; see the help for details.

  • Author

Will do. Thanks!

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.