• 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: Search/replace
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Search/replace


  • Subject: Re: Search/replace
  • From: deivy petrescu <email@hidden>
  • Date: Sat, 15 Mar 2008 13:54:58 -0400


On Mar 15, 2008, at 11:14, Gini Waters wrote:

Hi all
I'm am new to apple scripting. I'm not sure of the appropriate way to do this but I have a question. I'm trying to search and replace customer codes on a text file (usually Word) to my QuarkXPress tags. I've read a fair amount of posts, but haven't found the right example to build from.


--Here's what I'm working with:
<CN>Chapter 1 <CT>Is America at Risk?

<CHO>Chapter Objectives

After reading the chapter and reflecting on the contents, you should be able to:

<NL>1. Identify the concern for food safety and the presence of foodborne illness in the United States.

2. Articulate an understanding of the term "biotechnology" as it relates to genetically modified food.</NL>


<KT>Key Terms

agroterrorism—Includes purposeful adulteration/poisoning of agricultural crops and the food supply to cause illness or death.

biotechnology—Includes a gene slicing technique that enables scientists to insert genes into foods for the purpose of dealing with the environmental stresses the world now poses.

--I need to do Xpress tags that replace the <CN> with @CN: and also searches for bold or italic words and surrounds them with <B> or <I>. I thought it'd be a pretty straightforward script but am struggling.

--I've found a few scripts that I thought might work, but don't....


tell application "Microsoft Word" my ReplaceEverywhere("<CN>", "@CT:") end tell

I wrote this:
tell application "TextCommands"
search text "This is a customer code: <CN>Chapter Number <CT>Chapter Title."
[finding <CT>]
replacing with "@CT:"
end


The script didn't like the "<" character... Any suggestions you have would be greatly appreciated!
Gini _______________________________________________



This works: __________ set texto to "<CN>Chapter 1 <CT>Is America at Risk?

<CHO>Chapter Objectives

After reading the chapter and reflecting on the contents, you should be able to:

<NL>1. Identify the concern for food safety and the presence of foodborne illness in the United States.

2. Articulate an understanding of the term \"biotechnology\" as it relates to genetically modified food.</NL>


<KT>Key Terms

agroterrorism—Includes purposeful adulteration/poisoning of agricultural crops and the food supply to cause illness or death.

biotechnology—Includes a gene slicing technique that enables scientists to insert genes into foods for the purpose of dealing with the environmental stresses the world now poses.
"
set simbolos to {"CT", "CN", "CHO", "KT"}
repeat with s in simbolos
set s to contents of s
tid("<" & s & ">")
set texto to text items of texto
tid("@" & s & space)
set texto to texto as text
end repeat
texto



on tid(x) set AppleScript's text item delimiters to x end tid ____________

Note, you did not mention what to do with the closing tags if they are there.
so I skipped over <NL> and </NL>.



_______________________________________________ Do not post admin requests to the list. They will be ignored. AppleScript-Users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
References: 
 >Search/replace (From: Gini Waters <email@hidden>)

  • Prev by Date: Re: Date math problem in Leopard
  • Next by Date: Re: File best practice questions
  • Previous by thread: Re: Search/replace
  • Next by thread: Path to Document in Script Editor
  • Index(es):
    • Date
    • Thread