1 2 Previous Next 28 Replies Latest reply on Jun 18, 2017 6:54 PM by philmodjunk

    How to get filename of container field?

    aarjunmuthu

      Hi,

       

      I have a file in container field, how to i get the name of the file using script?. Thanks in advance.

        • 1. Re: How to get filename of container field?
          KylePutzier

          You can create a calculation field that is simply = YourContainerField or set a variable to YourContainerField

           

          Kyle

          • 2. Re: How to get filename of container field?
            aarjunmuthu

            Sorry can you please explain. I cannot get you. Thanks in advance.

            • 3. Re: How to get filename of container field?
              Stephen Huston

              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.

               

              Stephen Huston

              • 4. Re: How to get filename of container field?
                DavidJondreau

                The function GetAsText ( table::containerField ) will return the name.

                • 5. Re: How to get filename of container field?
                  aarjunmuthu

                  Thank you. Doing Good.

                  • 6. Re: How to get filename of container field?
                    TravisButler

                    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,411

                    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:)

                    size:0,0

                    movie:sromig_FMGO_1.2.mp4

                    moviemac:/<filepath>/sromig_FMGO_1.2.mp4

                     

                    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.png

                    size:601,411

                    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.

                    • 7. Re: How to get filename of container field?
                      PeterWindle

                      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:

                       

                      Let (

                      LastLine = GetValue ( GetAsText (Image_Container); ValueCount (Image_Container) );

                       

                       

                      Case (

                      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.

                      • 8. Re: How to get filename of container field?
                        albertov

                        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.

                        • 9. Re: How to get filename of container field?
                          Stephen Huston

                          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.

                          • 10. Re: How to get filename of container field?
                            albertov

                            My only observation was that:

                             

                            FileMaker 11 DOES return the size of an image with GetAsText(Container) when images are stored as reference only.

                             

                            However:

                             

                            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.

                            • 11. Re: How to get filename of container field?
                              comment

                              albertov wrote:

                               

                              GetAsText (myContainerName), Filemaker only returns "image:filepath" and NOT the size.

                               

                              Is this normal behaviour?

                               

                              Yes.

                              • 12. Re: How to get filename of container field?
                                beverly

                                albertov, try this function:

                                     Length ( myContainerFieldName )

                                This should return the KB of the file. There was quite a discussion on this recently:

                                 

                                     https://fmdev.filemaker.com/message/90033#90033

                                 

                                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.

                                 

                                Beverly

                                • 13. Re: How to get filename of container field?
                                  Grace

                                  I am using Pro 10 and GetAsText(myContainerName) only gives me a question mark.

                                  • 14. Re: How to get filename of container field?
                                    comment

                                    Grace wrote:

                                     

                                    GetAsText(myContainerName) only gives me a question mark.

                                     

                                    That will happen if you've pasted the image into the container field.

                                    1 2 Previous Next