6 Replies Latest reply on Aug 9, 2013 1:19 PM by bterrell721

    Selectively importing records from folder



      Selectively importing records from folder


           I have a folder of images that I regularly add to, and then update records in filemaker so that the new images are imported and properly matched to those records.  However I am starting to find that as more and more images are placed into the folder it is starting to take far too long to import as it is actually importing and then checking every single image in the folder for matching records each time even though the majority have already been imported into filemaker previously.  Is there a way to have filemaker selectively import images that have been added after a certain date, or to automatically move image files to a different folder after importing?  I know I can just manually move all the images into a different folder after I do an import, but for the convenience of my users an automatic solution would be much more beneficial.  Thank you very much!

        • 1. Re: Selectively importing records from folder

               FileMaker may need some "help" to do that. Here are some options to investigate:

               If you place your folder inside Documents. There's a get function you can use to list all files and folder in documents so you could set up a script that gets the list of file names and checks them off against existing records with matching file names to import only the new files.

               If the folder is located anywhere but inside Documents, you'll need to use either a system script or one of the available plug ins to get a list of files from a specified folder.

               You can use FileMaker to copy a file from one folder to another by inserting the file into a container field and then using export field contents to export it to the second folder, but FileMaker cannot delete the original file from the original folder. You'd need to use another system script or plug in to manage that action.

               Note: I have a FileMaker 10/11 system where we do exactly this. We use digital cameras with WiFi capable SD cards to take pictures that the SD Card's software has been configured to upload to a specific shared directory on our server. A Script then imports all such files into a table in the database and exports them back out to a different shared directory on the server and then exports/executes a batch file that deletes each of the original files by name from the "in box" folder so that the next import records action does not import them again.

          • 2. Re: Selectively importing records from folder

                 Awesome, that is exactly what I needed to know, thank you.  Any tips on where to look for how to set up a batch file that does the deleting?  I can manage the scripting and exporting in FM, but I have not created a batch file before.

                 Edit:  Figured out how to make the batch file, but what script do I use in Filemaker to execute it?  I am running Filemaker Pro 12.  Thanks!


                 On a side note:  Is the SD card you use an Eye-Fi Card?  If not, what kind is it and are you happy with the performance?  I do something similar with a portable scanning device that functions like a digital camera, but I find that the Eye-Fi card I use constantly drops off my wifi and is unable to transfer images consistently unless I am standing right next to my network router with it.

            • 3. Re: Selectively importing records from folder

                   Since the batch file has to include data from my file. I have a table of batch file commands grouped by a name that describes the purpose of that set of batch commands. I use Export Records with the option to automatically open the file to export the text to my temporary folder.

                   The table from which I export has a field for the batch ID, a field for the basic command, a parameters field and a calculation field set to return text that combines the command with the parameter.

                   My script finds the records for the specified batch file, updates the parameter fields of those records to insert the needed names and then uses export records to export just the calculation field.

              • 4. Re: Selectively importing records from folder

                     Thanks again for the tips.  I think for me (and anyone else possibly trying to do what I am) it works perfectly to just use the Send Event script step after I run my import and have it execute a simple batch script that moves all the files from my "Images" folder into an "Imported Pics" subfolder and call it good.

                • 5. Re: Selectively importing records from folder

                       Yep. As long as you can get a "canned" batch file to do the job, you don't most of  need the additional details that I specified. I used the method I used as there are several people that can be taking pictures all at the same time and I have to make sure that a picture file doesn't get deleted before it can be imported into the database so I have to delete records by name only after I am sure that I have imported and moved the files.

                       You do have one detail to look out for: What you describe works fine for embeded files. If you use the "store a reference" option, however, the file move will break the container field's reference to the file as it is referring to the original location in the first folder. That's why I export from the container field and then re-insert. It updates the file path data in the container field to link to the correct new location at the same time that the file is moved.

                  • 6. Re: Selectively importing records from folder

                         Good to know.  I can't use references because this database is also utilized on mobile devices and those images need to be available there, but that is a handy note.  Thanks!