5 Replies Latest reply on Apr 7, 2016 10:36 PM by AndyE

    Renaming Exported Photos From a Portal

    Cal10026

      Hello All,

       

      I am a new FMP user and I was hoping someone could help me with a small problem I have come across. I have an Events table which has a portal displaying pictures from a related Pictures table.  I would like to know how to display how many portal rows are within each record in a separate field.

       

      I will use this information to then build upon my photo export script. When I export the photos in the portal I would like to customized the image name. For example, if a record only has two photos in the portal then photo one is exported to the desktop with an image name "a" and photo two is "b" and so on.

       

      I hope this makes sense. I am happy to provide a copy of my database if it would help with clarification.

       

      Thank you,

       

      Cait

        • 1. Re: Renaming Exported Photos From a Portal
          erolst

          Cal10026 wrote:

          When I export the photos in the portal I would like to customized the image name. For example, if a record only has two photos in the portal then photo one is exported to the desktop with an image name "a" and photo two is "b" and so on.

           

          Why would you have to know how many photos there are? Start with a and end with a + (n-1) …

           

          What I mean is that the algorithm doesn't change with the export count (which is a good thing in an algorithm …).


          e.g.

           

          If [ IsEmpty ( Images::primaryKey ) ]

          Exit Script

          End If

          Go to Related Records [ Images ( Images ) ; related only ; match current only ; new window ]

          Go to Record [ first ]

          Loop

          Set Variable [ $fileName ; Images::id_event & "_" & Char ( Get ( RecordNumber ) + 96 ) & ".jpg" ]

          # [ Consider that photos from a later export would have the same name as some (or all) photos of an earlier one, so you would overwrite these older ones … so let's add the eventID to the name ]

          Set Variable [ $exportPath ; Get ( DesktopPath ) & $fileName ]

          Export Field Contents [ Images::theImage ; $exportPath ]

          Go to Next Record [ exit after last ]

          End Loop

          Close Window


          Already thought about found sets > 26?

          • 2. Re: Renaming Exported Photos From a Portal
            Cal10026

            ,

             

            I am not sure if this changes things or not. In total I would like each photo exported to have this naming structure YYYYMM_SiteName_T##_dis##_abcde (each of these pieces are fields within the Events table) (abcde being the photos in the portal). Knowing how many portal rows is not really necessary, just thought it might help organize things.

             

            The last piece stumping me getting the abcde portion.

            I would like to have :

            201109_SARI_T05_dis01_a

            201109_SARI_T05_dis01_b

             

            This would be representing that field "dis" 1  that has two photos in the portal.

             

            Another possibility is the next record is "dis" 2 which now has three photos in the portal. I would like each photo to be renamed upon export to these:

             

            201109_SARI_T05_dis02_a

            201109_SARI_T05_dis02_b

            201109_SARI_T05_dis02_3

             

            Would your suggestion work as the last piece of my current script?

             

            script.jpg

             

             

             

             

            Thank you for your help! This is the last piece of the puzzle for this script.

             

            Cait

            • 3. Re: Renaming Exported Photos From a Portal
              keywords

              Cal10026 wrote:

              The last piece stumping me getting the abcde portion.

              I would like to have :

              201109_SARI_T05_dis01_a

              201109_SARI_T05_dis01_b

              This would be representing that field "dis" 1  that has two photos in the portal.

              Assuming you are doing the export all at once via a looping script, I suggest you consider tracking the "dis" part as a variable which you update as each loop is completed. This would be easier if you used numbers instead of letters, but still possible either way.

              • 4. Re: Renaming Exported Photos From a Portal
                Cal10026

                This is very close! But I need the letter characters to recycle when a number entered in a field changes.

                 

                For example when the field "dis" is 1, it could have 3 photos in a portal on that record. These three photos would be "a","b","c",.

                 

                The next record may be "dis" is 3, and it has two photos in a portal on that record. These photos need to be named "a","b"

                 

                The letters are dependent upon what number is entered in the "dis" field. When the number changes, I need the letters to start from the beginning of the alphabet.

                 

                Thank you for your help!

                 

                Cait

                • 5. Re: Renaming Exported Photos From a Portal
                  AndyE

                  If you modify the above suggestions slightly to add a check for new "dis##" and a counter that resets as part of the Loop section of the script, it should go back to "a" when required. See attached image.Screen Shot.png

                  Of course this is a fairly simple counter which will only go up to 26 (i.e. a to z). If there's no chance there will be more than 26 related images it's not a major issue. However you could modify it further with a more complex counter to accomodate more if required (i.e. aa to zz).