Exactly where do you encounter trouble? Can't get the name of the file or can't get Insert PDF to work?
Thank you for replying Phil.
I run into problems with "copying" the PDF file name and adding it to the file path as a variable ($FilePath)
"Copying" from where? A field in your database or is it that you need a list of all files in the specified folder so that you can use them to build the needed paths in the variable?
If you need the list of directory contents, you may need to do one of the following:
- Get a plug in. Don't know if it's FMP 12 compatible, but mooplug is free and incldes a function for listing directory contents.
- Move the folder in to your documents directory. Theres a get function that will list all the files and folders in your documents folder so you can parse the list returned to extract the names and file paths of all objects enclosed in a directory IF it's inside the documents folder.
I would need it to search a directory on my hard drive. I could definitely move the directory of PDFs to my documents folder and use the get function that you mentioned in your option 2. The function is "Get ( DocumentsPathListing )" which would seem to me as a good start to what I'd like to do. Here's an example of some of the text I received form using Get ( DocumentsPathListing ):
The text in blue are the individual folders that are named after the record's serial number and the text in green are the names of the PDF files that i've been trying to get. How would I then go about filtering that huge list of file paths down to single out the one directory line i'd like to set as a variable?
Thank you Phil; I think I'm almost there!
For starters, you don't need to separate out the text in green. You can assign an entire line from this listing to your $FilePath variable to get the path to the file in it's temporary, documents directory based location.
The first entry for the goup of items inside this diretory will be the path to the dirctory itself:
So you can use code such as:
Set Variable [$PathsList ; value: Get ( DocumentsPathListing ) ]
Set Variable [$K ; value: $K + 1]
Exit loop if [GetValue ( $PathList ; $K ) = "/Macintosh HD/Users/Me/Documents/DatabaseFiles/Files/Database/FILES/FIL0008/"]
Exit Loop if [ $K > valuecount ( $PathList )]
To loop through the entries until you get to that first one, then you can loop until the leading text changes to that of a new directory.
I help another user by creating a demo for this type of "batch Insert" in an .fp7 file you can examine: https://www.dropbox.com/s/1lg85eymwpymsh8/BatchFileInserter.fp7