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

Find and swap position of period/footnote

Community Beginner ,
Jul 06, 2020 Jul 06, 2020

Copy link to clipboard

Copied

Hi everyone,

 

Hoping someone can help out. I have a document with about 200 references (footnotes). I need to swap the position of the full stop (or period) so that it appear after the footnote.

 

For example, the current layout is:

Sentence.Footnote

(Or with numbers: Sentence.12)

And I need:

SentenceFootnote.

(Sentence12.)

 

Is there a way to use find and replace to swap these around? I can easily find the instances by using 

.^F

but I don't know enough to code the swap. I don't fancy manually searching through 200 references to fix them all!

 

Any help would be very much appreciated.

Thanks

Andy

TOPICS
How to , Print , Scripting , Type

Views

697

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

correct answers 1 Correct answer

Community Expert , Jul 06, 2020 Jul 06, 2020

There must be scripts around to do that. but it's easier to rekey it than to look for it:

 

app.findGrepPreferences = app.findChangeGrepOptions = null;
app.findGrepPreferences.findWhat = '[[:punct:]]~F';
found = app.documents[0].findGrep();
for (i = found.length-1; i >= 0; i--) {
   found[i].characters[0].move (LocationOptions.AFTER, found[i].characters[1]);
}

This one swaps any punctuation and a following footnore number. Maybe the script should cater for strings of punctuation.

 P.

Votes

Translate

Translate
Community Beginner ,
Jul 06, 2020 Jul 06, 2020

Copy link to clipboard

Copied

Some example images of the text as it is:

Screenshot 2020-07-06 at 20.51.12.png

 

 

And how it should look after:

Screenshot 2020-07-06 at 20.51.51.png

 

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 ,
Jul 06, 2020 Jul 06, 2020

Copy link to clipboard

Copied

There must be scripts around to do that. but it's easier to rekey it than to look for it:

 

app.findGrepPreferences = app.findChangeGrepOptions = null;
app.findGrepPreferences.findWhat = '[[:punct:]]~F';
found = app.documents[0].findGrep();
for (i = found.length-1; i >= 0; i--) {
   found[i].characters[0].move (LocationOptions.AFTER, found[i].characters[1]);
}

This one swaps any punctuation and a following footnore number. Maybe the script should cater for strings of punctuation.

 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 Beginner ,
Jul 07, 2020 Jul 07, 2020

Copy link to clipboard

Copied

Hi Peter,

 

Many thanks for your reply. It took me a little while to figure out what to do with that code – I'm a complete novice when it comes to scripts! But once I had figured out how to get it into a suitable format and imported in to InDesign, it worked like a charm. So thanks again. 

 

The only improvement would be if it could specify which type of punctuation – in this case I had some brackets and quotation marks that got swapped along with the full stops.

 

Andy

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 ,
Jul 07, 2020 Jul 07, 2020

Copy link to clipboard

Copied

If you want to swap just the period and the footnote marker, use this:

'\\.~F'

 And to use some spcific punctuation, more than one, e.g. period, comma, and semicolon, place them in brackets:

'[.,;]~F'

 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
Explorer ,
Dec 23, 2023 Dec 23, 2023

Copy link to clipboard

Copied

Hi Peter,

Thanks for all of your scripts!

 

That script also works with an anchored object (which, like footnotes, is also deleted by search and replace)

I can't get it to change beyond one character.
Suppose I have an anchored object and then text in text in brackets:
~a\(\w{1,3}\)
And I want to change $2$1
How do you do that?

 

Thank you

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 ,
Dec 24, 2023 Dec 24, 2023

Copy link to clipboard

Copied

LATEST

To move anchors after a parenthetical following them, use this:

app.findGrepPreferences = null;
app.findGrepPreferences.findWhat = '~a\\(\\w{1,3}\\)';
found = app.documents[0].findGrep();
for (i = found.length-1; i >= 0; i--) {
  found[i].characters[0].move (LocationOptions.AFTER, found[i].characters[-1]);
}

 

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