how to find duplicate paragraphs in a document?

Is is possible for Pages to scan a lengthy document to find duplicate paragraphs?

Posted on Apr 2, 2021 11:30 PM

Reply
Question marked as Top-ranking reply

Posted on Apr 3, 2021 8:53 PM

Try this script:


tell front document of application "Pages"
	set paraList to {}
	repeat with aParagraph in paragraphs of body text
		tell aParagraph
			if (it as text) is in paraList then set its color to "red"
			set end of paraList to it as text
		end tell
	end repeat
end tell


  1. Copy-paste the script above into Script Editor (in Applications > Utilities).
  2. With your document open in Pages click the <run> button in Script Editor.


This should turn duplicate paragraphs red.


(If the script doesn't seem to be running, make sure Script Editor is listed and checked at System Preferences > Security & Privacy > Privacy > Accessibility.)


SG


9 replies
Question marked as Top-ranking reply

Apr 3, 2021 8:53 PM in response to Casuarina

Try this script:


tell front document of application "Pages"
	set paraList to {}
	repeat with aParagraph in paragraphs of body text
		tell aParagraph
			if (it as text) is in paraList then set its color to "red"
			set end of paraList to it as text
		end tell
	end repeat
end tell


  1. Copy-paste the script above into Script Editor (in Applications > Utilities).
  2. With your document open in Pages click the <run> button in Script Editor.


This should turn duplicate paragraphs red.


(If the script doesn't seem to be running, make sure Script Editor is listed and checked at System Preferences > Security & Privacy > Privacy > Accessibility.)


SG


Apr 3, 2021 12:23 AM in response to Casuarina

Not without outside assistance.


That assistance can come from the user supplying a phrase to the Find / Replace with feature that, if detected at more than a single location in the document, would indicate the possibility of a duplicate paragraph.


Or it could come from an Applescript that reads and stores the first few words of each paragraph, compares them with the strings it has already saved from previous paragraphs, and flags, or otherwise gives notice of a posible duplicate.


The script would have the advantage of reducing user activity to starting the script, reading the results, and acting on those results.


There are a few talented script writers participating in these communities. With luck, one will read this thread and take on the exercis of writing this script.


Regards,

Barry

Apr 3, 2021 1:47 PM in response to Casuarina

"It’s a shame Apple doesn’t"


Hi Casualina,


Use the Provide Pages Feedback menu item in the Pages menu to send Apple a Feature Enhancement request.


Here, you are in a user-to-user community, where Apple's participation is minimal, and does not usually include participation by product development team members.


Regards,

Barry

Apr 3, 2021 1:52 PM in response to Casuarina

Due to MS Word having a great many handy features that corporations have required over the near 40 years of its evolution when a particular feature does not appear in Pages, I may recommend one of these alternatives:

  1. Just use the free LibreOffice, or MS Word (depending upon availability)
  2. Export the Pages document to Word .docx, and then perform the Word-specific magic in either of the two previous applications. Then open in Pages again.

Apr 4, 2021 4:51 AM in response to Barry

In LibreOffice v7.1, all one has to do is select an entire specific paragraph that is suspected of duplication. Click Edit menu > Find and Replace, and then click the Find Next button. This will select the next duplicate paragraph, and one can press backspace to remove it or take some other action on the duplicate paragraph. I suspect with appropriate regular expression syntax, one can tell it to take action on a specific capture instance.

Apr 3, 2021 8:22 PM in response to VikingOSX

Hi VikingOSX,


Happy to see you in this conversation (and others, of course).


I did check the LibreOffice site for possible instructions on this task. Vast quantities of documentation, but a search for 'find duplicate paragraphs' didn't turn up much n the way of useful information. There was a link to LO's community forum, but there the most topic connected post was one with a link to "the other forum," which, when clicked led to the ApacheOpenOffice community forum, where there was a series of posts on "How to Find Duplicate paragraphs," including two with scripts. One appeared to be a 'native environment' script for .odt files, the other was a script using perl.


Has 'find duplicate aragraphs' become a built in feature of LibreOffice, or does it still require a script?


And turning to Pages, could this be accomplished with a script?


Regards,

Barry

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

how to find duplicate paragraphs in a document?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.