Skip to main content
Participant
May 17, 2010
Question

Find and place CS4 JS

  • May 17, 2010
  • 1 reply
  • 436 views

Hi all,

I would like the script to run through each line of the file, search the  InDesign file for that number, and if it finds it place the icon I  specify after the text it just found. Here is some pseduo code I've been trying to figure out by piecing together other scripts.

while(input.hasNext())

{

     var text = input.nextLine();

     if(textExists == true)

          app.findTextPreferences.findWhat = text;
          app.changeTextPreferences.changeTo = text + " " + place("C:\\catalog\\icons\\Icon_install.ai") after the text  found;
          myDocument.changeText();

     else

          go to the next line

}

I would be using a text file that has part numbers in it like

4005

4003

5007

etc

I know a bit of java from school but not much JS. I'm really sorry for being so sloppy, but I'm new to JS. Any help would be appreciated.

This topic has been closed for replies.

1 reply

Harbs.
Legend
May 17, 2010

Do you need the same icon each time or a different icon for each?

If it's the same icon, you have two options:

1) You can copy it to the clipboard and use find/change to insert the clipboard contents (like you would in the UI).

2) You can serach the document and use iterate through the finds using

finds.insertionPoints[-1].place(myFile)

or (if it's in the clipboard)

app.select(finds.insertionPoints[-1])

app.paste()

Harbs

jimmy_popAuthor
Participant
May 17, 2010

Yes I will be using one icon per list of numbers. Are you saying to put all of the part numbers in an array? Also, I don't want to replace the contents of what I find, I just want to add the icon directly after the number it has found.