AnsweredAssumed Answered

Use Variable to create path for Insert File

Question asked by kayakjunkie on May 18, 2012
Latest reply on May 18, 2012 by kayakjunkie


Use Variable to create path for Insert File


I'm having trouble using a variable to indicate the file to be inserted into a container field.  If I type the text into the script directly, no problem.  If I use a variable which holds the exact same string, it pops up a dialog and asks me to choose a file.



I have several thousand files with source data that has been read into my database.  These files need to be archived in case they might be needed again at some point in the future.

I had been planning to simply keep them in a folder in Dropbox & Crashplan.  However, it appears that FMP's Container field could be very useful.  By inserting the files into a container field but using external, open storage, I have the ability to search for files from a specific day (or range of dates).

I've generated a list of all the files (e.g. /Users/Jesse/Dropbox/Databases/Portfolio Center/Source Files/Archive/20081028.EXE) into a table.  My script will go down the list, when it finds an .EXE or .ZIP file, it takes the date portion of the file name and performs a find in the Path Field of the Table.

This returns all the files that were available on that date, typically 3 - 6 files that were in the compressed .exe or .zip file.

I'm then looping through the found set, picking up the file extension.  Depending on the extension, the script goes to a different field in the Source Files table and executes an Insert File script step.

Using text functions the insert file path has been shortened to File:Source Files/Archive/20081028.EXE.

I'm having trouble with the Insert File script step.  If I go into the Insert File script step and type in File:Source Files/Archive/20081028.EXE in the dialog for Specify source file the file is inserted into the container field.

However if I define a variable $InsertFile = File:Source Files/Archive/20081028.EXE and type $InsertFile into the Specify source file section, I'm presented with a dialog to select a file.

The highlighted line fails, the line below it works.  However, that isn't very useful with over 4,000 files to process.  Sigh.