If you use Import Records | Folder to import the image files, you can designate that a text field in the table can receive the file name during import.
And the following calculation can extract the file name from a container field:
//This should work for all insertion and storage methods except Insert Object (Filemaker 11, WIndows only):
Let ( [ T = If ( LeftWords ( YourTable::ContainerFIeld ; 1 ) = "remote" ; GetValue( YourTable::ContainerFIeld ; 1 ) ; GetValue ( YourTable::ContainerFIeld ; ValueCount ( YourTable::ContainerFIeld ) ) ) ;
L = Length ( T )];
If ( LeftWords ( T ; 1 ) = "remote" ; Right ( T ; L - 7 ) ; Right ( T ; L - Position ( T ; "/" ; L ; -1 ) ) )
You are the best. Let me test this, will report back in a few minutes.
Going to have to report tomorrow, day ended too fast! thanks.
Good Morning, Phil.
Very nice, worked like a charm. Thank you. Do you mind explaining some of the code for me as a learning experience?
Do you know of any way to bring in images in an import like you would files? In other words, in a batch process and not one at a time?
Curious if FMP12 has the capability to do this.
To repeat my last post, you can use Import Records | Folder to bring in an entire forlder of images. A field for the file name can be designated as part of the import.
Before I attempt to explain the calculation, please confirm that you have looked up each function from that calculation in FileMaker help if it is unfamiliar to you.
You can also see this thread to get a file where you can see what text is in a container field and how different insertion and storage methods change what text is present: Exploring the use of a $Path Variable in Scripts
I have the following book:
by Bob Bowers, Dawn Heady, Steve Lane, Scott Love
I went through and read up on each of the functions and acquainted myself.
(PS: DOH! on the import folders, right under my nose, thanks!)
Ok, then if you download the file from the thread that I recommended, you can insert a file into the container field and then click the tab to see the text that is accessible in that file. The text that appears depends on the insertion method selected and whether the "store a reference" option is selected when you insert the file into the container. If You have FIleMaker 12 and external storage is specified for your field, this also changes what text is accessible from the container field.
The calculation you see was created by me after carefully studying the text accessible in a container field for each of the different variations. I use the Let function to both simplify it by assigning specific sub values to variables so that the expression doesn't have to compute the same value over and over again and also to break up the calculation into more manageable "chunks".
Then, when someone posted that they couldn't get the file name for an externally stored container field, I took another look at this for container fields and figured out a modification that works with them as well.
IF store a reference is not specified and the field does not have external storage, the only text available is the name of the file.
If Store a reference is specified, there will be two or three lines of text separated by returns. GetValue is used to extract a specific line of this text. Since the last line of text will be the file path to the file and this contains the filename, I use GetValue ( FIeld ; ValueCount ( Field ) ) to get the last line of text whether there are 3 lines of text (Inserted Picture) two (inserted file), or one line (store a reference not used).
Then I need all text to the right of the last / in the file path. I use the position function to get the position of the last instance of that character. By specying the position of the last character of this text (using the length function to get this position and setting it to L) and -1 as parameters to this function, it searches the text from right to left starting with the last character and thus returns the position of the last / in the text.
The length of this text (L) minus the position of the last / tells me the number of characters for the file name so that I can use it with the RIght Function to return just the text to the right of the last /, which will be the file name.
Also, I have been able to do a "batch insert" of files from a folder that are neither picture nor text files using a script but without using a plug in or a system script provided that I locate that folder inside the documents folder.
Thanks, Phil. This is excellent work. I am going to go over it in detail later today. Thanks for your patience and detailed help, greatly appreciated.