I have a file in container field, how to i get the name of the file using script?. Thanks in advance.
You can create a calculation field that is simply = YourContainerField or set a variable to YourContainerField
Sorry can you please explain. I cannot get you. Thanks in advance.
Create a calculation field and define it by simply placing the Container field name in the calculation definition, nothing else, no functions at all, but be sure to set this Calculation's RESULT TYPE to be TEXT. (At the bottom of the calc definition area.)
The text returned by this calc will be the file name of the item stored in the container field.
The function GetAsText ( table::containerField ) will return the name.
Thank you. Doing Good.
To note, this is not always the case, and the behavior is different in Filemaker 12 when you use remote container field storage.
When you insert something in a container field and use 'Store only a reference to the file' - in either FM11 or FM12 - what you get is something like:
size:601,411image:Screen Shot 2012-04-24 at 9.26.18 AM.pngimagemac:/<filepath>/Screen Shot 2012-04-24 at 9.26.18 AM.png
image:Screen Shot 2012-04-24 at 9.26.18 AM.png
imagemac:/<filepath>/Screen Shot 2012-04-24 at 9.26.18 AM.png
where the exact metadata depends on what kind of file you inserted. (This was an image; inserting a QuickTime Movie in 11 gets something like:)
When you insert something in a container field in FMP 12 without storing a reference, and have remote container field storage turned on, you'll get something like:
remote:Screen Shot 2012-04-24 at 9.26.18 AM.pngsize:601,411PNGf:Sample Container 1/Screen Shot 2012-04-24 at 9.26.18 AM.png
remote:Screen Shot 2012-04-24 at 9.26.18 AM.png
PNGf:Sample Container 1/Screen Shot 2012-04-24 at 9.26.18 AM.png
which is similar to what you get when inserting by reference, but somewhat different information in a different order.
The only time you actually get just the filename is when you store the container contents in the database without using remote container field storage.
I have a client who has images stored remotely on a server, accessed by both platforms,
I have created a calc that shows the filename as such:
LastLine = GetValue ( GetAsText (Image_Container); ValueCount (Image_Container) );
Abs ( Get ( SystemPlatform )) = 1;
Substitute ( LastLine; "imagewin:"; "imagemac:");
Substitute ( LastLine; "imagemac:"; "imagewin://STORAGE-PC/")
I created the substitutions so that the paths would be accessible for other functions (like plugins that can do things with the files)
Note that on Windows, there is a difference in how files are referenced, on a mac, if the volume is mounted, it's available, on windows, I needed to specify the volume.
I would just like to report that, in my experience, if you make a batch import of images (thousands of jpgs in my case) using:
File > Import Records > Folder (Import only as reference), using matching fields to update records, and then perform the calculation:
GetAsText (myContainerName), Filemaker only returns "image:filepath" and NOT the size.
Is this normal behaviour?
In order to obtain the width and height of each image (without plugins or upgrading to FMP12): Is the only way then to script a process that goes record by record and reinserts the image in the container field?
I am using Filemaker Pro 11 Advanced on Mac.
FM12 will return more information than FM11 for the "GetAsText (myContainerName)" function.
Because you are storing only a reference, the filepath sounds like correct information for FM11. The image data itself is not part of the FM11 file when stored as reference only, so obtaining calc results on the image are limited.
My only observation was that:
FileMaker 11 DOES return the size of an image with GetAsText(Container) when images are stored as reference only.
1) If you insert images using the convenient batch import and specifying that they should be imported only as reference then GetAsText return only the filepath.
2) If you script the process of looping through all the records, going to the container field and then using Insert Picture[Reference, $file_path], then you DO obtain the size.
In both cases I am inserting images as reference only, but I am obtaining different results.
At least this is what seems to happen in my (very limited) experience. For my database, it was important to evaluate if an image had a landscape or portrait orientation.
Thanks for your time.
albertov wrote: GetAsText (myContainerName), Filemaker only returns "image:filepath" and NOT the size. Is this normal behaviour?
albertov, try this function:
Length ( myContainerFieldName )
This should return the KB of the file. There was quite a discussion on this recently:
See if that helps for what container field info you get and with what version of FMP and of course how the container is stored.
I am using Pro 10 and GetAsText(myContainerName) only gives me a question mark.
Grace wrote: GetAsText(myContainerName) only gives me a question mark.
GetAsText(myContainerName) only gives me a question mark.
That will happen if you've pasted the image into the container field.
To be precise, the file was inserted into the container field by "insert object". I am having great difficulty getting the file path in my script. Any suggestions will be greatly appreciated.
Yes, Grace. this is a copy straight from FM10 functions reference (help topic):
The data returned can be a field type number, date, time, timestamp, or container.
For a container field, GetAsText returns external path information, text (when the container contains text that does not resolve into a valid path), or a question mark (?) if the container data is embedded in the database.
So, it would appear that you inserted (or pasted) the graphic/file into the "myContainerName" field.
Some versions allow you to put just the name of the field into a text result calculation, and get something. I'll have to test on FM10.
My results for both calculated getastext and the calculated container field name:
1. Insert => just the name of the file when I do NOT check the "Store only a reference to the file"
2. Paste => "?"
3. Insert => the size (dimensions), name of the file, the path to the file when I do check the "Store..."
Using FM10 Advanced
So it seems you pasted into the container field. Is that your conclusion, too?
I am processing the existing data. I doubt the file is embedded in the database since I cannot export the content of that container field. The quesiton mark makes it more likely to be Pasted though.
Grace wrote: To be precise, the file was inserted into the container field by "insert object". I am having great difficulty getting the file path in my script.
To be precise, the file was inserted into the container field by "insert object". I am having great difficulty getting the file path in my script.
This is weird. If the file was embedded as an OLE object, then it has no path. Still, I believe* it should retain the original file's name. And it certainly should be exportable - as should a pasted image.
What type of object is it, and does it open in an external application when you double-click it?
(*) I cannot test this, as OLE linking and embedding is a Windows-only feature.
It puzzles me as well. It is PDF file. It opens in acrobat reader after double click.
Perhaps you should try saving it in Reader, then re-inserting it - this time as a file.
I tried the Length function on my container field which I am more confused about what is actually inserted there. For one record, the answer for Length is 1,473,929. The actual size of the pdf file is 880,640. For another record, the file size is same as previous one but the Length value is 19,525. Since I cannot export the contents of the container field from both records, I am quite sure the file itself was not inserted. The "Export Field Contents" works fine on another record which I used "Insert File" on a pdf file. But a 1MB long path? Something is so wrong.
Length(container_field) should be the SIZE (in Kilobytes) of the physical document (as the OS would report it), not the path of the document. Again, depending on the version of FileMaker AND how the file is stored. This may or may not be as expected.
I generally use GetContainerAttribute ( My::container ; "filename" )
This works with externally stored containers.
Please note the 5 year difference between your post and the previous one. That function may not have even been available yet.
This solution it works, but only with new datas. How can I refresh all old data?
Which solution? Two are described here, one that has worked across many different versions.
What do you mean mean by "old data "?
might it be an inserted object in the container field? Don't think that there's a filename to extract in that case. (Insert object is no longer supported by currrent versions. )
I'm working in FM14 but I dont found sotored/unstored calculation
pls help me, how can I recalculate old container's file name data
Sorry, but what you have posted does not make sense. Can you explain in more detail what you are trying to do?
Note that how the file was inserted into the container field and the container field storage options defined for the field all play a role in what you can do with the file (or the reference to the file) that has been inserted into the file.
Questions that should be answered before anyone can help you:
What exactly do you mean by "recalculate an old container's file name data"? Can you provide an example?
How was the file inserted? Insert file, insert Picture, Insert PDF, or ???
Was the "store a reference" option specified?
Was external storage specified for the container field? If so, was it secure external storage?
Retrieving data ...