7 Replies Latest reply on Jun 16, 2016 9:36 PM by brucewilson

    Import Records from Folder


      I am managing my scanned invoice PDFs with FileMaker Pro.  I scan each invoice to a folder called APInvoices.  I have the setting saved on my scanner.  A few times during the week I import the content of the folder into container fields, creating new records for each.  After the import I move the PDFs to a folder called \SCANNED which is under \APInvoices. 


      My problem is that since I import the PDFs into the file, it is getting large.  But my understanding is that if I imported the reference to the PDFs, I could not change their location, i.e. moved to \SCANNED.  But if I do not move, then won't they get scanned each time?  I am so confused.


      On a positive note, I have been doing this for about three months, and it has made my work so much better since I can see the invoices without going to the fileroom.  I have a script to export field content and create email.  Saved me several times.  I just need to resolve the file size issue.


      What am I missing?

        • 1. Re: Import Records from Folder



          You could do a Container with External Storage to keep your file small.  Same issue if you move them but at least they are out of your database.


          • 2. Re: Import Records from Folder

            Well, what you describe would be a Catch 22 when using a reference. You could of course import them after you added them to \SCANNED folder.


            From the back slash path syntax I take it you're on Windows; on OS X, I'd have suggested using a folder action with an AppleScript to automate the import of newly added documents; not sure if/how this can be automated under Windows.

            • 3. Re: Import Records from Folder

              I add files as references, then move the file (manually or using a plugin) and run a script like this


              set variable ( $FilePath ; "filewin:/X:/APInvoices/Scanned/" & GetValue ( ContainerField ; 1 )

              Insert File [ Table::ContainerField ; $FilePath ] (as reference, no dialog)

              • 4. Re: Import Records from Folder

                If it were me I would use External storage for the container field, import the PDFs using Import Folder, then delete everything in the folder (since External storage means the original scans are no longer needed). The folder is then empty and ready for use next time.

                • 5. Re: Import Records from Folder

                  In English can you explain what is happening.  I presume I am running your script on the found set (newly created records).  But I am unclear what is happening.

                  • 6. Re: Import Records from Folder

                    Yes, I am running this on Win10.

                    • 7. Re: Import Records from Folder

                      Oops: the first line of code should be

                      set variable ( $FilePath ; "filewin:/X:/APInvoices/Scanned/" & Substitute ( GetValue ( ContainerField ; 1 ) ; "file:" ; "" )


                      In a calculation, a container field has a list of characteristics, the first item in the list contains the file name.

                      I use GetValue to extract that, Substitute to remove the prefix, then add the full path of the folder where the PDF is moved to, and put that all into a variable.

                      That variable is then used as the source of the Insert step.


                      You would run that on each newly created record, so a loop would be good.


                      NOTE: This assumes that all users are on Windows and can see the PDFs at the same drive mapping.

                      Some more complexity is required if there are other platforms or drive mappings involved.

                      ... or you could use External storage.