7 Replies Latest reply on Feb 11, 2010 12:24 PM by ShirleyMB4

    SCRIPT TO IMPORT PHOTO IMAGES

    ShirleyMB

      Title

      SCRIPT TO IMPORT PHOTO IMAGES

      Post

      There is a folder with hundreds of JPGS, each of which I have to insert into the appropriate record. I've made a calculation field for the name of the JPG, since the JPG name corresponds to the Filemaker record ID. The calculation is as follows: If ( RECORD ID < 100; "PIC-01-00" & RECORD ID & "A.jpg"; "PIC-01-0" & RECORD ID & "A.jpg" ). When trying to make a script, I want to insert the images automatically using the above calculation, but the file path allows for only a specific image (imagewin:/C:/PIC-01/fileName). How do I get "fileName" to be shown as a calculation field and not as a specific JPG name?

        • 1. Re: SCRIPT TO IMPORT PHOTO IMAGES
          Marx
            

          If I understand, you would need a looping script with insert file command with its (insert file) file name parameter defined as a variable.

           

          The $file variable must be formatted correctly, i.e. "filewin://...the full path.../the filename.ext"

           

          I would suggest using global variables as one learns, i.e. $$file ...

           

          e.g.

           

          Go To Record [First] 

          Loop

            Set Variable[ $$file ;Value:"filewin://C:/PIC-01/" & If ( RECORD ID < 100; "PIC-01-00" & RECORD ID & "A.jpg"; "PIC-01-0" & RECORD ID & "A.jpg" )]

            Insert File[ target::field ; "$$file" ]

            Go To Record [Next;Exit After Last]

          EndLoop

           

          Of course values could vary depending on requirements. 

           

           

          • 2. Re: SCRIPT TO IMPORT PHOTO IMAGES
            ShirleyMB4
               Thank you for your speedy reply. I know that I have to loop the script, but before that I had wanted to get the script to work! What I don't know is the info you had written: "I would suggest using global variables as one learns, i.e. $$file ...." What do the dollar signs mean? I'm not that expert on programming at a higher level, so any help would be greatly appreciated. Thanks again.
            • 3. Re: SCRIPT TO IMPORT PHOTO IMAGES
              Marx
                

              Shirley,

               

              Not a problem.

               

              The variable is about the only way to accomplish the task.

               

              A quick explanation is a

              $ variable is local to the current script execution - it releases from memory when script exits, e.g. $myname = Marx;

              and a $$ variable is global to the session and lives on after the completion of a script, e.g. $$myname = Marx

               

              we use these to pass information, settings, data etc. during FileMaker sessions.

               

              For details see FileMaker Help File "Designing and creating databases -> Using variables" 

               

              You can start with just two steps from previous email to test:

               

              Set Variable [...

              Insert File [ ...

               

              This will allow you to test your variable setting and if the insert file step will work.

               

              Hope this helps. 

               

              • 4. Re: SCRIPT TO IMPORT PHOTO IMAGES
                ShirleyMB4
                   Thanks again. I'm still not sure if I understand completely, but I'll work on it. If I run into a problem, you'll be hearing from me!
                • 5. Re: SCRIPT TO IMPORT PHOTO IMAGES
                  ShirleyMB4
                     The insert file script allows only number results, so the "; "$$file" doesn't work. I still don't understand how the script you provided allows the matching of the Filemaker record to the image in the folder.
                  • 6. Re: SCRIPT TO IMPORT PHOTO IMAGES
                    Marx
                      

                    I think you might have entered quotes rather than a variable reference - when you specify the file on the insert file script step you would type $varname NOT "$varname" or "$$varname" quotes around the variable name would cause double quoting and filemaker would error out on the syntax.

                     

                    The work of assuring that the content of that variable is a valid path and conforms to an existing file is something you have to be sure of - the help file has extensive notes about file path use as a variable.

                     

                    If scripting is not the way you want to proceed, you could approach a solution from another direction - i.e. "Import Folder" command will collect all image files in separate records into a new table which you could then match up by some text manipulations to their appropriate record.

                      

                    • 7. Re: SCRIPT TO IMPORT PHOTO IMAGES
                      ShirleyMB4
                         Thank you for your feedback. In the interim I've made a very elementary script which is working quite well. I'll study your notes some more so that I could learn how to do scripting properly! Thank you again.