Skip to main content
andyizzle
Participant
Jul 6, 2020 7:47 PM UTC
Answered

Find and swap position of period/footnote

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

Peter Kahrel
Peter KahrelCorrect answer
Community Expert
Jul 6, 2020 9:03 PM UTC

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.

8 replies

Participant
May 3, 2025 9:34 PM UTC

What are you supposed to do with these scripts. I tried entering them in "find and replace," but it doesn't work.

Translate
Robert at ID-Tasker
Legend
May 3, 2025 9:43 PM UTC
quote

What are you supposed to do with these scripts. I tried entering them in "find and replace," but it doesn't work.


By @salomonq

 

https://creativepro.com/how-to-install-scripts-in-indesign/

 

Translate
Peter Kahrel
Community Expert
Community Expert
Dec 24, 2023 11:19 AM UTC

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]);
}

 

Translate
andyizzle
andyizzleAuthor
Participant
Jul 6, 2020 7:54 PM UTC

Some example images of the text as it is:

 

 

And how it should look after:

 

Translate
Peter Kahrel
Community Expert
Peter KahrelCommunity ExpertCorrect answer
Community Expert
Jul 6, 2020 9:03 PM UTC

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.

Translate
andyizzle
andyizzleAuthor
Participant
Jul 7, 2020 9:36 AM UTC

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

Translate