Skip to main content
andyizzle
Participant
July 6, 2020
Answered

Find and swap position of period/footnote

  • July 6, 2020
  • 3 replies
  • 1702 views

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

Correct answer Peter Kahrel

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.

3 replies

Participant
May 3, 2025

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

Robert at ID-Tasker
Legend
May 3, 2025
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/

 

Peter Kahrel
Community Expert
Community Expert
December 24, 2023

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

 

andyizzle
andyizzleAuthor
Participant
July 6, 2020

Some example images of the text as it is:

 

 

And how it should look after:

 

Peter Kahrel
Community Expert
Peter KahrelCommunity ExpertCorrect answer
Community Expert
July 6, 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.

Peter Kahrel
Community Expert
Community Expert
July 7, 2020

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


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.