Back

If your email is not recognized and you believe it should be, please contact us.

  • You must be logged in to reply to this topic.Login

Searching for a script to import variable images …

Return to Member Forum

  • Author
    Posts
    • #57866
      gamouning
      Member

      Hi,

      Does anyone know of a script that can find text and import an image? I have about 600 photo images in jpg format. Each photo is named, Lastname_Firstname.jpg. I have created a data merge which has the following text:

      Insert_Photo_Image:Lastname_Firstname.jpg

      I would like to do a search on the above text, then use the Indesign Place command to insert the appropriate image.

      FYI, I am using InDesign CS3 on a PC.

      Thanks in advance for any assistance you can provide.

      Greg

    • #57868

      there's a better way:

      https://www.scriptopedia.org/in…..navlang=en

      perfect for graduation photos with headshots

    • #57869

      actually, i mis-read your post… sorry :(

      the words are within the text and you want to replace the text with the actual picture… got it.

      this one works by finding text which has @ symbols at the start and end of the filename.

      _____

      // reset the Find/Change dialog

      app.findGrepPreferences = app.changeGrepPreferences = null;

      // formulate a grep search string

      app.findGrepPreferences.findWhat = '@.+?@';

      // find all occurrence, last one first

      f = app.activeDocument.findGrep (true);

      for (i = 0; i < f.length; i++)

      {

      // construct file name

      name = f[i].contents.replace (/@/g, '');

      // place the pdf and REPLACE the destination with the folder of links

      f[i].insertionPoints[0].place (File ('—–replace this bit——' + name));

      }

      // delete all @??@ codes

      app.activeDocument.changeGrep()

      _____

    • #57873
      gamouning
      Member

      Dear Collywolly,

      Thank you for both replies. I may be able to use your first one for a different project in the future.

      The second reply sounds like just what I need. However, it seems to be calling for the incorrect sub-directory(folder) that contain my images. Can you tell me what I need to change in the code so that it will look in the following server sub-directory:

      X:AMCurrentWorkMN009213GDESIGN_printLAYOUTPhotos

      With much appreciation,
      Greg

    • #57878
      gamouning
      Member
      Hi,

      In my previous reply I noticed the slashes were dropped between the subdirectory names. I will try posting using the Paste with Word option instead:

      X:AmCurrentworkMn009213Gdesign_printLayoutPhotos

      Hopefully you will see the blackslashes. If not, please know there is a backslash prior to each capital letter.

      Regards,

      Greg

    • #57880
      gamouning
      Member

      I did some searching through the InDesign Secret Archives and found the following solution to add back slash to a post by David Blatner:

      To type a backslash, you can type:
      & # 9 2 ; (with no spaces in between)

      Below is my post using the above method:

      X:&#92AM&#92CurrentWork&#92MN009213&#92GDESIGN_print&#92LAYOUT&#92Photos

    • #57881
      gamouning
      Member
      X:\AM\CurrentWork\MN009213\GDESIGN_print\LAYOUT\Photos

      X:&92;AM&92;CurrentWork&92;MN009213&92;GDESIGN_print&92;LAYOUT&92;Photos

    • #57885

      Did you think of placing your path in the line that says

      f[i].insertionPoints[0].place (File ('—–replace this bit——' + name));

      ? It really really looks to me a path should (could) be in there.

    • #57886
      gamouning
      Member

      Hi Jongware,

      Yes, that is what I thought too. My file is located on a server with a path name assigned to X. For example, I used the following:

      f[i].insertionPoints[0].place (File (X:\AM\CurrentWork\MN009213\GDESIGN_print\LAYOUT\Photos\+ name));

      Does that look correct to you?

      -Greg

    • #57887
      gamouning
      Member

      FYI, I have uploaded this script and replaced my folder string with '–replace this bit–'. It is available via my Public Dropbox link from the following weblink:

      https://db.tt/FhEvhtS

      I would appreciate knowing what I am doing wrong.

      -Greg

    • #57888

      Ah — just thought of this. Are there single backslashes in that string? Since this is a Javascript string, the backslashes act as escape characters, so you must double them — like this: X:\YourPathHere\AndSomeMoretc-etc. Alternatively, I think InDesign's Javascript also recognizes the single forward slash as a path separator, so you could try that as well.

    • #57889
      gamouning
      Member

      Thanks Jongware, you were correct again. I often forget to double up on the backslashes when working with javascript. :( This script is working now. :)

    • #57926
      gamouning
      Member

      Hi,

      I've done a bit more testing and this script is working great. Is there anyway to add “Fill Frame Proportionally” and change the frame box size to 0.75″ w X 1″ h?

      -Greg

    • #64001

      I am so happy I found this site! Thank you goes to collywolly for putting your script here! I just copied it and tried it out and it's going to save me a lot of trouble! We produce testprep books and the math section has lots of MathType equations embedded throughout the Word doc. I import the file into Adobe InDesign CS(don't remember which version but it's a book we update every year) now we have Adobe InDesign CS6. When I do that the equations become Windows metafiles. I unembed them all creating .EPS files that I store in a folder. What we have found is that sometimes type disappears from the equations and there's no rhyme or reason for it happening. The first PDF file I send to editorial looks good, but when I make their corrections to text and create a NEW pdf file, the people in editorial find missing text and wonder why since the text was there in the first pdf! My research points to METAFILES. I didn't want to go back to importing each one individually, so I decided to search for a script. This script works wonderfully (except the equations are not centered vertically on the line so I'll be looking for a solution for that problem) and I wanted to let anyone who lands on this page know that it's a good script! It will save me a lot of time. If anyone knows how to get inline graphics to center vertically on a text line or have a script that can select all objects and apply an object style (the select objects script that came with ID doesn't select the imported equations for some reason) let me know. Thanks!

      Linda

    • #64002

      I just tried something and it works for most fraction equations. I used Find & Change and selected GREP. I searched for ~a (that's what I got when I copied the imported graphic with my text tool) and changed Advanced Character Format – Baseline Shift to -0p9. That works if you are using 10pt type with auto leading. I sometimes have to open up the leading to 18pts. That's probably the best option. Then I would fix any Arithmetic long division or multiplication graphics manually. Considering there are many more fractions in this book, this method will save time. If anyone finds a better way, let me know. I'm subscribed to this topic. Thanks! :)

    • #82277

      I’d just like to point out that I was not the author of the script that is the third post in, that was Kasyan Servetsky. The original can be found at: https://forums.adobe.com/thread/289071?start=0&tstart=0

      That said, he has developed an improved version: https://kasyan.ho.com.ua/place_images.html

Viewing 15 reply threads
  • You must be logged in to reply to this topic.
Forum Ads