Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 2844 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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.

 

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

Posted

Wim, 

This is the script as it stands now.

Got Record/Request/Page [First]

Loop

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.

Posted

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:

http://www.filemaker.com/help/14/fmp/en/html/scripts_ref1.35.57.html

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

This topic is 2844 days old. Please don't post here. Open a new topic instead.

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
×
×
  • Create New...

Important Information

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