Skip 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.

Importing a folder of images

Featured Replies

Hi Gang,

I am attempting to import a folder of images to one of my tables. I go through the "Import Records" step, and select "Folder" and images. I am only storing a reference to the image. What I also need to do as I import the images into the table, is to automatically assign an ID field to each new image/record, that comes from another field in another table. In the one import process, all the images will be assigned this same value. But on another import, the ID may change. How can I achieve this with Scriptmaker. I am new to the FM world so I apologize if this is too basic a question.

Many thanks,

Nando

I dont think you can read in and import a folder of files even in FM8 without the Troi File Plug-in.

I used the plug-in to have the user select a directory and then read in all the files in that directory and then import them into a table in FM7.

What I also need to do as I import the images into the table, is to automatically assign an ID field to each new image/record, that comes from another field in another table. In the one import process, all the images will be assigned this same value. But on another import, the ID may change. How can I achieve this with Scriptmaker.

First, John, you can import a folder of images, which is what Nando is doing without a problem. What he/she wants to do is to assign all the records imported an ID from another table.

What you need to do is to run a scripted operation just after the Import Folder, while the records are still the found set. It could be a Loop, with Set Field [] or a Replace Field Contents [], to put the ID into its field in all the records. You are going to have to put the ID into a global field first (or into a Script Parameter {from a button}, or into a Script Variable {8 only}). Since we don't know exactly how you're going to pick this ID from the other table, we can't really say which of these is best. But it needs to be in something that is accessible from all records in the images table.

If, for example, you are running the script from the table with the ID (which makes the most sense, since you have to choose the ID otherwise), then you know what ID you're on. I'm going to set it into a global in the script below.

Freeze Window

Commit Records [no dialog]

Set Field [ global ID, ID ]

Go to Layout [ Images (Images table) ]

Import Folder [ the images folder ]

Go to Record [ First ]

View As Form (if it is a list view)

Loop

   Set Field [ Images::ID, Other table::global ID ]

   Go to Record [ Next, exit after last ]

End Loop

Go to Record [ First ]

View As List (if it was a list view to start with)

Commit Records [no dialog]

(P.S.

1. You can set or get a global from any other table occurrence. Doesn't even require a relationship.

2. View as Form will make a Loop go many times faster on a List view layout. But you want to switch back when you're done. If it's a Form view to start with you don't need those steps.

)

I believe you can save yourself the entire post-import operation, by defining the ID field to auto-enter the globalID. Then it's simply:

1. Set globalID to desired value;

2. Import (with "Perform auto enter.." selected).

  • Author

Thank you Fenton. A quick question before I try this. How can I loop through the records and assign it the global value, if I have other photos on the table with a different ID (that is not meant to change)?

Thank you very much!!

Nando

You don't have to worry about other records. Because after an Import of new records you always have only the records that were imported as the found set. Loops only work within the found set.

But use comment's advice. It is a much better way to get the ID automatically, at the same time as the Import; no script needed afterwards. Leave the [x] Allow auto enter calculations checkbox checked (the 2nd dialog of the import).

  • Author

Guys, THANK YOU!! It works like a charm. You guys are awesome....!

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

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.