Peter Barfield

batch import via script

4 posts in this topic

Not sure if this is the relevant area however, I couldn't seem to find a scripting section

What I would like to do and I have had no success so far is the following scenario.

I have database which stores references to files in container field located on a folder on a shared computer.

What I want to do is have a script which when run populates the database with the names of those files located in the folders on the computer and create a new record for those not already present and if they are already present ignore the import.

I have tried a test script which gets the documents path and loops through each record however I get file unknown when debugging and that is as far as it goes.
The script in no one handles the above scenario of omitting and inserting only new docs it was just a test to see if it was possible to import via this method. From what I can see the script is asking for a particular filename and if it can't be found it throws the error. That though is no good as essentially the filename is in a sense unknown at the time of import and that is what the purpose of the script would be i.e. too find those files and create a new record with reference only in a container.

Documentation on this is either non existent or sparse and confusing to say the least (or at least that's how I find it)

Any enlightenment would be appreciated.


Share this post

Link to post
Share on other sites
11 hours ago, Peter Barfield said:

I have tried a test script which gets the documents path and loops through each record however I get file unknown when debugging and that is as far as it goes.

You get that error on what part of the script?  Can you post your script?  That will help us debug.

Share this post

Link to post
Share on other sites


This is the script as it stands now.

Got Record/Request/Page [First]


Insert File [Reference;Never compress; Table:: Field; "".""]

Go to record/Request/Page [Next Exit; after Last]

End Loop.

I know this is not going to do what i am after it was a test to see the idea behind the step Insert File. The script goes to the first record then displays the error unknown file and i am assuming that is because it can't find the ""."" file as it isn't a true file. I realise from what docs i have read if I specified a file that exists at that directory (let's just say ABC.txt) then it would work and import it into the field.

As I have explained I am working on the basis that I have no idea what docs or how many exist in that directory and they will be updated throughout the day and the directory will be populated throughout the day with new docs. I just want to import what is in the directory into a container field for each one in filemaker a reference to them. So in other words the script if it is possible would be along the lines of

Go to the directory specified

Get the first Document

Look in the filemaker table

if they document name does not exist

create a new record and insert the reference to the doc in a container field.

If it exists skip that one and go to the next and so on - loop through all the docs in the directory until finished.

I don't even know whether this is in the scope of filemaker or not.

Hope this makes sense.

Share this post

Link to post
Share on other sites

Sure it is...

The trick is knowing what file to insert, the "insert file" script step can take a variable as the path+filename so that's covered, see example 3 in the help:

So how do you know what files to loop through?  You can use the FM Get() functions to get a listing of a folder, or you can do a bit of OS-level scripting to get the file names in a folder or folder structure.

Once you have that input then you can loop through it and compare it against your data already in FM.

It's not clear from your description where you are stuck:

- in getting the list of files from a folder

- or comparing that input to your records

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • By BugsyOhar
      Over the past ten years our organization have been using a PO database solution to store all purchasing information. Each year
      the layout would change to illustrate which year it represents. We would like to merge each of these databases into one for better
      searching capabilities. Is there an easy way to accomplish this task while still maintaining data integrity? Thank you!
    • By Anna.anto
      Attention: Before posting in the general discussion forum please review the other forums that would best suit your topic.
      If you cannot find one then you may delete this text and post your topic in this forum.
      Hi all, I need to import into filemaker table an XML file as this:
      <?xml version="1.0" encoding="utf-8"?>
        <Field APIName="WrntyID">6029065</Field>
        <Field APIName="ExternalID">1761A</Field>
        <Field APIName="Name">sayIT SA</Field>
      now I'am trying to create the xls file.
      This is my xls file....
      <?xml version='1.0' encoding='UTF-8'?>
      <xsl:stylesheet version="1.0" xmlns:xsl="">
          <xsl:template match="/">
              <FMPXMLRESULT xmlns="">
                      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="WrntyID" TYPE="TEXT"/>
                      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="ExternalID" TYPE="TEXT"/>
                      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Name" TYPE="TEXT"/>            
                              <DATA><xsl:value-of select=“Account/Field[1]" /></DATA>
                              <DATA><xsl:value-of select=“Account/Field[2]” /></DATA>
                              <DATA><xsl:value-of select=“Account/Field[3]” /></DATA>
      This instruction <xsl:value-of select=“Account/Field[1]"/> doesn't work.
      What is the right syntax to retrive the value of the first TAG FIELD? Then the second end so on...?
      Many thanks
    • By jax
      Hi FMers,
      I'm trying to get multiple choice quiz questions into a FileMaker database. The information is in a plain text file. Question and options are simply separated by returns:
      Where in the cell is the genome located?
      Mostly in the cytosol.
      Mostly in the mitochondria.
      [X] Mostly in the nucleus.
      Stored in the membrane.
      Stored in RNA.
      Next question...
      Each question has 5 options, one of which is correct [X]. There's an empty line between questions.
      What's a good approach to get this into a FileMaker database with separate fields for the questions, the options, and the correct solution?
      All the best
    • By H
      Hi i created a certificate and want that when it is clicked to save it it gets created into a pdf and then imported into the cetification container field , however for some reason i am recieving some error  in my script  , the pdf does not save at all. 
      see script below:
      i would appreciate if someone could tell me where i went wrong why my pdf is not saving and if this is the method to save the pdf to a container
    • By shevyshevy
      I have come across this technique severally on this forum, but I can't figure out how this really works. Right now I am faced with a situation that requires similar technique and I can't seem to get it work.
      I have Table A and Table B.
      1. I want to script an import Process that will first export all records in Table A into Table B (kinda A Clone Copy of Table A) Thats just my basic objective
      2. Then from there, I would want to be able to do similar Process but this time, I will only update the records in Table B with that of Table A using a match field.
      3. I will also love to perform the process based on a found count. ie after performing a find of specific records
      I think If I can be guided on achieving NO. 1, then I can similarly script the others..