• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

ID CS3-5 grep notes in script fails, but in UI ok

New Here ,
Jun 07, 2018 Jun 07, 2018

Copy link to clipboard

Copied

Working with InDesign CS3-5 on MAC (no, not the newest system...)

Hello to You,

for months now I try to change Text with >changeGrep< in a text file that contains notes. (You can find those notes with >findText< "FEFF" or see/edit their content in the >text mode<.)

My data is:

<note1>X_S01002:M03<note2>Y_P00012 <+further data in line>

<note1>X_S03302:M03<note2>Y_P00312 <+further data in line>

My grep in UserInterface (cmd f) in InDesign is:

Search for: (X_S[0-9]{5,}):([A-Z0-9]{3,})(Y_P[0-9]{5,})

(it is set by the script below)

The items in (see brackets) are $1 $2 $3 and they shall be in order $1 $3 $2:

Change to: $1:$3-$2

(so $3 has to "jump" over <note2> to the left - or better: <note2> itself jumps in front of $1)

and the correct result is 2:

<note1><note2>X_S01002:Y_P00012-M03 <+further data in line>

<note1><note2>X_S03302:Y_P00312-M03 <+further data in line>

To do this in Javascript is

myMainDoc = app.documents.itemByName(app.activeDocument.name);

app.findGrepPreferences = NothingEnum.nothing;

app.changeGrepPreferences  = NothingEnum.nothing;

app.findGrepPreferences.findWhat = '(X_S[0-9]{5,}):'  //$1

                                                        + '([A-Z0-9]{3,})'    //$2

                                                        + '(Y_P[0-9]{5,})'    //$3

app.changeGrepPreferences.changeTo = '$1:$3-$2';

var myResults = myMainDoc.changeGrep();

The results = 0

That is: with this grep defined in script (and results =0) I change to InDesign and see the grep-definition in the UI, start it and get the results = 2 ! (see above)

I read about the notes being managed by the program itself. But why does it not work in the script? (It does not matter what the notes' content is.)

I allready changed my data to fixed length, but this did not make things better.

Thank You for help in advance or be welcome to the funeral of this concept

Dietmar

TOPICS
Scripting

Views

360

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jun 07, 2018 Jun 07, 2018

Copy link to clipboard

Copied

Hello,

If you want to manipulate the notes, not sure if you can do that with find grep. I suspect you have to access the notes directly, some thing like this.

notes = app.activeDocument.stories.everyItem().notes.everyItem().getElements();

You will also need to look at notes in tables.

P.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 07, 2018 Jun 07, 2018

Copy link to clipboard

Copied

LATEST

And not to forget: Notes in footnotes 🙂

Best,
Uwe

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines