I have used a script that takes any file inserted into a container, exports it to a folder on the server, then re- inserts itself as a reference to the file on the server so that it is accessible to anyone one the network.
While that isn't exactly what I need, I'd like to see it.
I used this in a quoting solution where I wanted to be able to store any number of files associated with a particular quote record. The files are stored in a container field in the Files table, Files::attachedfile. I setting the variables for the path so that the files would go into specific folders on the server for each customer. I set this to run on a script trigger, on field modify.
Set Variable [ $filename; Value:Substitute ( GetValue ( incoming::incoming ; 1 ) ; "file:" ; "" ) ] //gets the name of the file
Set Variable [ $filepath; Value:Quotes::foldername ] // gets the folder to save the file into
Set Variable [ $newname; Value:Quotes::quoteID & "-" & $filename ] //adds the ID# to the filename in case to prevent overwriting files with the same name.
Perform Script [ “create folder” ] //creates a new folder for a customer if one doesn't already exist
If [ IsEmpty ( incoming::incoming ) ] // makes sure there is a file in the container
Exit Script [ ]
Export Field Contents [ incoming::incoming; “filemac:/ServerX/$filepath/$newname” ] // saves the file into the folder on the server
Insert File [ incoming::incoming; “filemac:/ServerX/$filepath/$newname” ] [ Reference ] // re-inserts the file from the server as a reference
Once this is done, anyone reviewing the quote can double click the file in the container to open it.
Not sure how you would go about importing a whole folder at a time, unless you moved them to a flash card and used the import from digital camera function to create the new records in the File table. If you did that and one imported the files to be associated to a specific parent record you could use replace field contents to fill in the ParentID field to establish the relationship, since the newly imported records would be in the current found set.
You may want to investigate plug ins for Filemaker. There are some third party plug ins that can read a folder's list of files which you could then use with a script to insert each of the files in the directory into container fields of different records in the same table.
Thank you for this script. It's a different approach but I'll definately give it a try.
It does work well in that users can input files whether they are on the server, their desktop or anywhere else but they all end up in a central location so that anyone else can open the file and ensures that the files are stored as reference so that the file doesn't bloat up.
you could probably cut down on the variables, but I was trying to isolate the steps as I was trying to get it to work, and once it worked I didn't mess with it anymore. I added the $newname after realizing that some customers were scanning documents to send as email attachments and files like Scan001.pdf were being constantly overwritten. Adding the "quoteID-" to the filename ensures that each file will get a unique name, and if someone wants to manually look through the folders have that number to match the file to a quote.