6 Replies Latest reply on Jun 21, 2011 3:41 PM by Corné

    How to replace a bunch of photos?

    Corné

      Title

      How to replace a bunch of photos?

      Post

      Hello all,

      I need to replace a bunch of photos in the FM database. The current pictures are too large and slows down the database. Therefor I have resized the pictures and I need to replace them all. Thusfar I right-click the picture, choose 'Export Field Contents' so I can see the original name in the Save As dialog box. Then I lookup the resized model with the same name in a different directory and paste this in the container field; next record....

      I like to think there must be a smart way to do this, e.g. with a script. Unfortunately I haven't found the right way to do this. Have you guys any suggestions? All is well appreciated!

      All the best,

      Corné.

        • 1. Re: How to replace a bunch of photos?
          philmodjunk

          How do you know which new picture goes with which existing record for your updates? Are the images stored by reference?

          There may be a way to use Import Records | Folder to import all the new images and their filenames into a temporary file and then use a script or possibly replace field contents to move the pictures into the container field of the correct record in your original table.

          • 2. Re: How to replace a bunch of photos?
            Corné

            Hello Phil, thanks for dialing in!

            The images are not stored by reference. I guess that would make replacing the pictures a breeze. Reason not to do so in the past is that i thought it would result in a slower database, am I wrong? So they are actually stored in the .FP7 file.

            I'm not too sure about your possible solution. Do you suggest to create a separate FMP database to import all pictures? Would I use references now? And could you please give a hint what the script should look like?

            Thanks!

            • 3. Re: How to replace a bunch of photos?
              philmodjunk

              No need for a separate file, assuming you are using a recent version of FileMaker. If my idea is workable, you'd just add an additional table to the file you are already using.

              I didn't post a script example yet as I need to know whether there is data in your current table that can be used to compare to the file names of the new images so that the scritp can correctly match imported image files to the correct record in your table.

              If the current images were store by reference, we might have had a way to do this if the filenames of the original files have anything in common with the file names of the new images as there is a way to extract the filename of store by reference images from their container fields.

              • 4. Re: How to replace a bunch of photos?
                Corné

                I indeed use a recent version: 11.

                I would say that somehow it must be possible to compare filenames. Although the pictures are currently in a container, when I right-click the picture, choose 'Export Field Contents', I can see the original name in the Save As dialog box. Perhaps this value can be put in a variable, so with some script I could make a reference to the resized pictures?

                • 5. Re: How to replace a bunch of photos?
                  philmodjunk

                  Yes, you can get to the filename of the original file inserted as an image into the container field. I had to go back and look at a database where I experiment with container fields to confirm that.

                  No need for a variable here. If the file names of the original and edited images are exactly the same, the following method will work:

                  Define a new temporary table with two fields, a container field for the image and a text field for the filename.

                  Use Import Records | Folder to import all the pictures into this new table importing the image into the container field and the filename into the file name field.

                  Define a calculation field, cFileName, in your original table with a calculation that is simply the name of your container field. (The container field stores the filename so we can just refer to the field like it's a text field to get to the file name.) Select Text as the field's return type.

                  Now define this relationship:

                  OriginalTable::cFileName = TemporaryTable::FileName

                  Now you can go to the TemporaryTable's layout and use the field tool to add the Container field from your original table to this layout.

                  Now do the following steps:

                  1) save a copy of your file. This way you can try again if the following steps go wrong for you

                  2) Select Show All Records and click into the container field from your original file

                  3) Select Replace Field Contents and choose the calculation option

                  4) enter or select the name of your tempoary table's container field as the sole item in the specify calculation dialog.

                  5) click OK to dismiss dialogs and perform the replace field contents operation.

                  • 6. Re: How to replace a bunch of photos?
                    Corné

                    This looks promising!

                    Since it's 40 mins after midnight, I'll join my girlfriend to bed (how can I resist) I'll keep you updated on my progressions. Thanks again!