6 Replies Latest reply on Nov 2, 2011 1:55 PM by philmodjunk

    EXPORTING IMAGES from container with Different FILE TYPES

    blewvelvet

      Title

      EXPORTING IMAGES from container with Different FILE TYPES

      Post

      Hi.

      got a ton of Talent images..PDF, JPG, etc of various file types in a container field.

      I need have created some variables and able to export..but need to fully be able to:

       

      EXPORT the file - OK

      RENAME the file of the Full Name of the person - OKBUT The Filename should ALSO have the actual filetype extension of the file

      And save it on the desktop. - OK

      -------------------------------------------------------------------------------------------------

      I have a script that works..but only if I have one file type (i.e & ".jpg) in the variable. But if it's PDF..preview can't open it.

      I need to add to my script that basically get's the LAST 4 DIGITS including the period ".xxx" and add it to the end of the Talent name.

      here is what I have.

      ----------------------------------------------------------

      SET VARIABLE     $path

      "file:" & Get ( DesktopPath )  &  TALENT::TALENT First  & " "  & TALENT::TALENT Last & ".jpg"

       

      EXPORT FIELD CONTENTS -

      Target Field - TALENT::TALENT HEADSHOT

      Output File -

      $path
      filemac:/$path
      filewin:/$path

      --- with auto open file a the end.

      ------------------------------------------------------------------

      It's that damn forced ".jpg" as text that I need the script to look for the actual last 4 digits of the container field file name...and put it there.

      I know it's a "Get" function..but not sure how to manipulate it after that.

        • 1. Re: EXPORTING IMAGES from container with Different FILE TYPES
          mgores

          If you get as text (containerfield) you should be able to extract the original filename and use the Left text function to get the .xxx to get the right extension.

          • 2. Re: EXPORTING IMAGES from container with Different FILE TYPES
            philmodjunk

            No get function needed as far as I can tell from your post.

            Try this calculation to extract the file extension:

            Let ( [ R = GetasText ( ContainerField ) ; L = Length ( R ) ] ;
                    Right ( R ; L - Position ( R ; "." ; L ; -1 ) + 1)
                 ) // let

            • 3. Re: EXPORTING IMAGES from container with Different FILE TYPES
              blewvelvet

              Phil...Worked beautifully!!

              I did.

              SET VARIABLE $path

              "file:" & Get ( DesktopPath )  &  TALENT::TALENT First  & " "  & TALENT::TALENT Last & Let ( [ R = GetAsText ( TALENT::HEADSHOT RESUME ) ; L = Length ( R ) ] ;  Right ( R ; L - Position ( R ; "." ; L ; -1 ) + 1)  ) // let

               

              Was wondering, for archives and educational purposes..explain the why this "Let" statement works?

              I'm not sure how the --- L and R  - 1 + 1  --- items work. I'm dumfounded when I look at it. I would like to understand better.

              • 4. Re: EXPORTING IMAGES from container with Different FILE TYPES
                philmodjunk

                Let is a way to assign values to variables that can then be used either: inside the let function itself (what we did), in subsequent steps in the same script (If $ is used as the first character of the variable name) or throughout the data base file (If $$ is used as the start of the variable name).

                I used it to set up two variables, R and L. If you removed this let function, you'd have to replace R with the name of your container field and L with the length of the text from this container field.

                The position function can be looked up in FileMaker help. It's parameters are: text;searchString;start;occurrence

                We made L, the starting point so that Position first "looks" at the last character in R--the file reference stored in the container field. A negative value in the occurrence parameter makes the search work from right to left instead of left to right, so -1 tells the function to return the postion of the first "." found, starting from the last character and searching from right to left.

                If you had R = "FileName.JPG", L would be 12 and the position function returns 9. 12 - 9 returns 3, but we want the right 4 characters, not the right 3 so we add one.

                I'm embarrased to admit that I now see a much simpler expression: Right ( Containerfield ; 4 ) should work equally well here in place of this complex confection that I originally posted.

                • 5. Re: EXPORTING IMAGES from container with Different FILE TYPES
                  blewvelvet

                  Very interesting..funny how two answers can be done to get the same result.

                  In the shorter answer as replacement would be.

                  "file:" & Get ( DesktopPath )  &  TALENT::TALENT First  & " "  & TALENT::TALENT Last & Let (Right (Containerfield ; 4 )

                   

                  ..and is basically is saying ...get the the last 4 digits from the right side of the container contents name and place it here in the filename.

                   

                  Yes much simpler. Is this like algebra and simplifying the equation???

                  FYI..I didn't do well in algebra...but I get this easier than algebra.

                  • 6. Re: EXPORTING IMAGES from container with Different FILE TYPES
                    philmodjunk

                    AS I was finishing my previous post, it occurred to me that what you want will always be the last 4 characters of the text so there was no need to compute the position of the period that starts the file extension.

                    You don't need the let function in this last version. You can just use Right ( container field ; 4 )

                    Do calculations in FileMaker for awhile and you may find that you are better at algebra than you originally thought. Wink