• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: TextEdit find/replace script
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: TextEdit find/replace script


  • Subject: Re: TextEdit find/replace script
  • From: Bernard Azancot <email@hidden>
  • Date: Tue, 17 Oct 2006 18:38:24 +0200


Le 16 oct. 06 à 13:31, Rob Stott a écrit :

This won't win any prizes, but should do the job...

tell application "TextEdit"
	tell front document
		set theText to text 1
		set text 1 to my replaceTheText(theText, " cie ", " de ")
	end tell
end tell

on replaceTheText(theText, theFromString, theToString)
	tell application "TextCommands"
		search theText for theFromString replacing with theToString
	end tell
end replaceTheText

Thanks a lot Rob. You have shown me the way.

The poblem is that I have other OCR mistakes to corect.

So the script became :

-- Script --
tell application "TextEdit"
tell front document
set theText to text 1
tell application "TextCommands"
set theText to (search theText for " cie " replacing with " de ")
set theText to (search theText for " dc " replacing with " de ")
set theText to (search theText for "N) " replacing with "- ")
set theText to (search theText for " O," replacing with " 0,")
set theText to (search theText for "INDICAnON" replacing with "INDICATION")
set theText to (search theText for " ct " replacing with " et ")
set theText to (search theText for " L5-SI " replacing with " L5- S1 ")
set theText to (search theText for " slir " replacing with " sur ")
set theText to (search theText for " sIIr " replacing with " sur ")
set theText to (search theText for "inteme" replacing with "interne")
set theText to (search theText for "exteme" replacing with "externe")
set theText to (search theText for " ci '" replacing with " d'")
set theText to (search theText for " ci'" replacing with " d'")
set theText to (search theText for " quc " replacing with " que ")
set theText to (search theText for " jc " replacing with " je ")
set theText to (search theText for " nonnal" replacing with " normal'")
set theText to (search theText for " lc " replacing with " le ")
set theText to (search theText for " d '" replacing with " d'")
set theText to (search theText for " l '" replacing with " l'")
end tell
end tell
end tell


-- End of script --

The problem is that the changes are nicely made but only in the result pane. The text stays unchanged. :-(
How can I save those changes to the text.


I have  tried to be less awkward :

-- Script --
set searchList to {" cie ", " dc ", "N) ", " O,", "INDICAnON", " ct ", " L5-SI ", " slir ", " sIIr ", " inteme ", " exteme ", " ci '", " ci'", " quc ", " jc ", " nonnal ", " lc ", " d ' ", " l ' "}
set replaceList to {" de ", "de'", "- ", "0,", "INDICATION", " et ", " L5-S1 ", " sur ", " sur ", " interne ", " externe ", " d'", " d'", " que ", " je ", " normal ", " le ", " d' ", "l'"}
tell application "Tex-Edit Plus"
activate
tell window 1
repeat with x from 1 to the number of items in replaceList
replace replacing with item x in replaceList looking for item x in searchList ¬
with cases matching and whole words matching
end repeat
end tell
end tell


-- End of script --

This does not work at all.

Nothing is simple.
Friendly

Bernard _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: TextEdit find/replace script
      • From: Emmanuel <email@hidden>
    • Re: TextEdit find/replace script
      • From: Luca Pozzato <email@hidden>
References: 
 >TextEdit find/replace script (From: Bernard Azancot <email@hidden>)
 >Re: TextEdit find/replace script (From: Rob Stott <email@hidden>)

  • Prev by Date: Re: tutorial on HFS versus finder and POSIX file path ?
  • Next by Date: Re: tutorial on HFS versus finder and POSIX file path ?
  • Previous by thread: Re: TextEdit find/replace script
  • Next by thread: Re: TextEdit find/replace script
  • Index(es):
    • Date
    • Thread