1 2 3 Previous Next 37 Replies Latest reply on Nov 26, 2012 11:20 AM by ShirleyMB

    Automating JPG Insertion

    ShirleyMB

      Title

      Automating JPG Insertion

      Post

           I have 28 folders, each containing 3500 JPGs of file cards from which I have to enter the main info found on each card. I've created a calculation to name the JPGs (the JPG names are sequentially numbered), and I created a script to make a new record and to copy the JPG name. What I can't automate is the pasting of the JPG name into the JPG folder for the image to appear for each record. Is there a way to script the pasting of the JPG name into the folders? It takes a very long time to do so for the individual records. Also, if there is a way to script the paste part, how can one also script the creation of multiple records, with each record automatically entering the JPG?

        • 1. Re: Automating JPG Insertion
          philmodjunk

               Not sure what you mean by "pasting the JPG name into the folders"?

               What method are you using for inserting these files? Insert Picture or are you using the Insert Records | Folder tool to do a batch import of all the images in a specified folder?

               I'd guess that what you mean here is that you are having trouble including the correct folder reference in your script so that Insert Picture correctly inserts the file. Please confirm my guess and I'll then respond (unless someone beats me to it) with a sample calcualtion that puts the file path to the specified file into a variable which you then use in conjunction with the Insert step to insert the image file into a container field.

          • 2. Re: Automating JPG Insertion
            ShirleyMB

                 I am using insert picture as each JPG has to go with the corresponding record. I've attached a screen shot of the script.

                  

            • 3. Re: Automating JPG Insertion
              ShirleyMB

                   Here's a sample of a JPG name: ORG-25-1480A.jpg, with the ORG signifying the organization, the 25 signifying the folder, and the 1480A signifying the front of the index card picture. My calculation for the automatic creation of the JPG name is

              If ( RECORD ID LENGTH = 1 ;"ORG-" & ORG FOLDER NUMBER &  "-000" & RECORD & "A.jpg" ; "" ) &
                   If ( RECORD ID LENGTH = 2 ;"ORG-" & ORG fOLDER NUMBER &  "-00" & RECORD & "A.jpg" ; "" ) &
                   If (RECORD ID LENGTH = 3 ;"ORG-" & ORG FOLDER NUMBER &  "-0" & RECORD & "A.jpg" ; "" ) &
                   If (RECORD ID LENGTH = 4 ;"ORG-" & ORG FOLDER NUMBER &  "-" & RECORD & "A.jpg" ; "" )

                    

              • 4. Re: Automating JPG Insertion
                philmodjunk
                     

                          I am using insert picture as each JPG has to go with the corresponding record.

                     That can also be accomplished with Import Records | Folder, but let's stick with what you have here.

                     Your script has a number of issues:

                     Copy is not the best script step to use here, there are better alternatives, but your script is copying from an empty field and then there is no paste taking place either. Why do you want to copy this info?

                     The copy script step is failing to copy anything, if I understand the context to your script as you are first creating a new record. Either that or the context is for a different table and your copy step is referring to a record in a related table--also problematic given that you have just created a new records which then has all match fields that might be used in a relationship empty unless they are defined to auto-enter a value.

                     Please explain what in your database tables/fields can be used to determine the file name and the folder name to be used to find and insert an image file. Please describe the tables and relationships involved so that "each JPG has to go with the corresponding record" is possible here.

                      

                      

                • 5. Re: Automating JPG Insertion
                  ShirleyMB

                       When a new record is created, the JPG name is automatically created with the record, so I am copying and pasting the JPG name reference.

                  • 6. Re: Automating JPG Insertion
                    philmodjunk

                         We're posting at the same time. What kind of field is RECORD? An auto-entered serial number?

                         You can simplify your calculation to be:

                    "ORG-" & ORG FOLDER NUMBER &  Right ( "-000" & RECORD ; 5 ) & "A.jpg"

                         The missing bit of data here is the location of the enclosing folder. Org Folder Number tells us the name of this directory, but not the location.

                         To insert your image, you can use a script like this:

                         New Record/Request
                         Set Variable [$Path ; "file:" & "/path to org folder goes here/" & Org Folder Number & "/" & "ORG-" & ORG FOLDER NUMBER &  Right ( "-000" & RECORD ; 5 ) & "A.jpg" ]
                         Go to Field [JIAS Records::Card Front]
                         Insert Picture [ Reference ; $Path ]

                         To refer to $Path in the Insert File script step, click the Specify button for this script step and type in $Path (no quotes) into the dialog that this opens.

                         But please note that you'll need to come up with a file path to your enclosing folder.

                    • 7. Re: Automating JPG Insertion
                      philmodjunk

                           Correction:

                           That calculation for the file name should be:

                      "ORG-" & ORG FOLDER NUMBER &  "-" & Right ( "000" & RECORD ; 4 ) & "A.jpg"

                      • 8. Re: Automating JPG Insertion
                        ShirleyMB

                             The "000" was given as an example for the 1st JPGs, which have been numbered as 0001, 0002, etc., up to 3500 - so I think the "000" calculation you showed won't work here. Also, even if I enter the path, how does that allow automatic insertion of the picture with the creation of many records?

                        • 9. Re: Automating JPG Insertion
                          philmodjunk

                               Using the corrected form, the calculation will work here, I've used it in many other situations. Try it and see.

                               The script example I posted creates one new record and inserts the corresponding image file. I suggest getting that to work first.

                               Once you can do it for one record with one image file, you can set up a looping script that does this for many files. You would need the user to specify a number as to the number of files to insert, use a plug in that can go to the folder and list the contents in order to determine the number of files, or you'd place your Org folder inside the documents folder so that Get ( DocumentsPathListing ) can be used to generate the list of files to be inserted.

                          • 10. Re: Automating JPG Insertion
                            ShirleyMB

                                 I plugged in the path: imagewin:/C:/Users/owner/Documents/JIAS CARDS/jias 25 partial, but I keep on getting a message "file could not be found; could not complete the script step..." To which file are they referring? I've tried to fool around with different file names (e.g. card folder name), but nothing seems to work.

                            • 11. Re: Automating JPG Insertion
                              philmodjunk

                                   Don't use imagewin: in this file path. Start with file: instead. I think, for that matter, that you can just start the path with C:. imagewin: is a tag  used inside your container field, but isn't used in other places where we specify a file path in FileMaker. And keep in mind that even the slightest error in your file path will generate this "file not found" error message.

                              • 12. Re: Automating JPG Insertion
                                ShirleyMB

                                     Now I get a message saying that the JPG picture could not be found (I used your JPG name calculation). I'm getting desperate here!

                                • 13. Re: Automating JPG Insertion
                                  philmodjunk

                                       Does the error message display the correct file name?

                                       If you open the specified directory, do you see a file with that exact name (file extension may not be visible)?

                                  • 14. Re: Automating JPG Insertion
                                    ShirleyMB

                                         I also realized that I should keep my own JPG name calculation because of the zeros only appearing with the earlier JPGs. If this is correct, should I insert that field in the Set Variable?

                                    1 2 3 Previous Next