8 Replies Latest reply on Nov 23, 2008 3:43 PM by phillman5

    Get file name from a container field.

    jasondeike

      Title

      Get file name from a container field.

      Post

      I am wondering how I can get just the file name from a container field.  I have a file that has a bunch of pdf's stored in a container field.  I want to be able to get the name of the pdf file to show in a list view.  Right now in the list view I have the container field showing which causes a slow calculation because it has to load a preview of each file in the container field.  However if I can just have a function that will return just the file name it should be much quicker to load.  

       

      Thanks for your help.

       

      Jason 

        • 1. Re: Get file name from a container field.
          Orlando
            

          Hi Jason,

           

          You can do this with a calculated field. create a new field and within the calculation dialog set the calculation to just the container field, and change the Calculation result to be Text. 

           

          DisplayFileName =

            ContainerField 

           

          Now depending on how the file is actually stored, Inside the container field in the database or as a File Reference the result will be different.

           

          For files storred inside the container field you will get the file name, job done.

           

          If the file is stored as a File Reference, and the actual file is on your computer or network somewhere you will see a result similar to this:

           

            file:filename.doc

            filemac:/Volume/Users/yourname/Documents/filename.doc 

           

          For this you will need to add an addition calculation to get the file name:

           

          DisplayFileName = 

            Substitute ( GetValue ( ContainerField ; 1 ) ; "file:" ; "" )

           

          This will get just the first line and remove the "file:"

           

          If you wanted to extract the filepath you could change the number "1" to a "2" and "file:" to "filemac:" or "filewin:" depending on platform.

           

          I hope this makes sense and helps.

          • 2. Re: Get file name from a container field.
            jasondeike
              

            That did the trick.  

             

            Thank you very much for the quick response.

             

            Jason 

            • 3. Re: Get file name from a container field.
              lcangus
                

              This works on many of my pictures, but some of the results are simply "?". 

               

              Does anyone know what that means and how to get the actual file name.

               

              Thanks very much.

               

              Lisa 

              • 4. Re: Get file name from a container field.
                raybaudi
                  

                Hi

                 

                Pictures are images, not pdf files.

                So a calc field, result text and calc = container returns:

                a) the image name when the picture is stored
                b) 3 line of data like these when picture is only referenced:
                size:80,83
                image:../../../FM/dan.jpg
                imagewin:/C:/FM/dan.jpg

                To get the name in case b) a calc can be:

                Let(
                value = GetValue ( container; 2 );
                Middle ( value ; Position ( value ; "/"; 1 ; PatternCount ( value ; "/" )  )  + 1 ; Length ( value ) )
                )


                • 5. Re: Get file name from a container field.
                  lcangus
                    

                  Thanks very much for your reply however...

                   

                  My results are sometimes C.  The calculation actually returns the correct file name in some records OR a question mark in other records.  Not the file name as is A. and not the file path as in B.  I did not put the pictures in the file and do not know the method they were put in so am at odds as to a method of getting the actual name if possible.

                   

                  Again, any thoughts or suggestions will be appreciated.

                   

                  Thanks very much, Lisa 

                  • 6. Re: Get file name from a container field.
                    raybaudi
                      

                    A possible c) result:

                     

                    You or someone else pasted the picture on the FM layout, copied it and pasted into the container.

                    • 7. Re: Get file name from a container field.
                      lcangus
                         Someone else actually did it but you are exactly correct!  Thank you.  Lisa
                      • 8. Re: Get file name from a container field.
                        phillman5
                           I am not sure this is exactly correct, but hey I am a novice.  But if the files is stored as a file reference, the first element of the list returned is not "file:name.doc"  but the relative path to the file name, so if the file is several folders deeper this element will have severeal folder names before the actual file name.