5 Replies Latest reply on Aug 9, 2013 3:05 PM by philmodjunk

    Importing Multiple files at once.



      Importing Multiple files at once.


           I'm working on a project in which I have to import multiple files into another existing file. I'm hoping to to do this without having to import each file one by one. I know that it is possible to import multiple image or text documents at once using the folder import. Is there a way to do the same for Filemaker files? 

        • 1. Re: Importing Multiple files at once.

               Am I correct that you want to insert files into container fields in FileMaker?

               Yes, this can be done, but the devil, as always, is in the details.

               The easiest way to do it that does not require plug ins or system scripts is to put the files in a folder inside your documents folder. Then a script can acquire the list of file names inside that folder and loop through them with Insert File to insert each listed file into a container field of a different record.

               The key function that makes it possible to get your list of files is Get ( DocumentsPathListing ).

               This also requires an understanding of how file paths, container fields and $Path variables can be used in a script. This thread provides a useful way to learn more about this: Exploring the use of a $Path Variable in Scripts

               And by using either a system script or a plug in, you can get the same list of file names from a folder located outside the documents folder.

               And here's a link to a demo file that I created for another poster here in the forum that had the same question: https://www.dropbox.com/s/1lg85eymwpymsh8/BatchFileInserter.fp7

               If you are using FIleMaker 12, just open this file from the File menu to get a copy converted to the FMP12 file format.

          • 2. Re: Importing Multiple files at once.


                 Thanks for your quick reply.

                 No, I'm not trying to insert files into container fields. Sorry, my original post was a little ambiguous.

                 As an example, if there are two FP7 files that have identical schema. I would like to import the records of one file into the other, therefore appending the records of one to the other. This is a trivial task when dealing with just 2 files. But I need to import  the records for 2300 .fp7 files.

                 I tried to create a script to do this using the Import[] step. To this object  I added multiple file names using the file selector that pops up when you double click on this object in the script. The information in this window states that file maker wil search for files in the order they appear. However, when I run the script only one file gets imported (records append) to the open file.

                 It seems that multiple import only works when importing into a container field. And filemake imports can only be done one at a time. Is that correct?

            • 3. Re: Importing Multiple files at once.

                   Yes, you have misunderstood the documentation on this dialog. FileMaker goes down the list of file references until it reaches one that is valid, but then it stops, imports records from that file and that's it.

                   A single Import records step will import records from a single file.

                   But you can adapt the method I have described for inserting files to that of importing records from multiple files. Use Import records with a $Path variable inside a loop, assigning a different file path to the variable each time through the loop. Please refer to the info in the links that I have already shared as the one on $path variables includes specific technical info on the import records step on how to use the variable but still have valid field mapping in place.

                   All of this assumes that the tables in each of these files have exactly the same fields and field names.

              • 4. Re: Importing Multiple files at once.


                     I am not able to open the second link on the first post that you sent to me.

                     As for using an $Path variable,  I understand the concept. However, I'm not sure how I can write this script.  It does not look like I can grab this syntax from the left hand side of the edit dialog and writing free text is not an option. Perhaps this is explained in the link i cannot open?




                • 5. Re: Importing Multiple files at once.

                       The second link is a down load link to my drop box folder where I keep the demo file. I just tested the link and it correctly opens to a web page where I can click a button to download the file. And the link to the FileExtractor demo file in the thread I suggested also works.


                            As for using an $Path variable,  I understand the concept...

                       No offense, but then I'm not sure that you do understand the concept. Did you read the thread? Did you download the FileExtractor demo file inside that thread and read/experiment with what it contains?

                       When you add a script step to a script, you must add it by double clicking the script step. But once you have added it, you can open up dialogs that specify additional infor for that script step. One of those dialogs for Import Records is for specfiying the file from which you will import and you have described that dialog previously in this thread. Instead of entering the path to an actual file, you type in the exact name of your variable ($Path in my examples) and then add a second file reference as the next line that you use so that you can open up the field mapping dialog and successfully map fields. These details are all covered in the thread and the FileExtractor demo file that I recommended.

                       Note that the BatchFIleInserter file will be less useful to you. You can look at it's script to see how you can get the list of files from inside a folder in Documents and get a file path to each one. Those file paths are what you would use with Set Variable [$Path , to set up a series of Import Records actions to import all your data.

                       Please also note that you will need to add additional scripting to update any auto-entered serial number fields so that the next serial value setting does not enter a value in a new record that duplicates the value of one of the imported records.