🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #15847

Re: search with wildcards not working properly in AppleScript

#15847
From: Olav_Kvern
Date: Fri, 07 Nov 2003 20:17
55 lines
2867 bytes
Ton--

Here's an example AppleScript. There's actually an advantage to letting AppleScript do the find/change operation for you--this approach doesn't replace the return characters, so you won't have styles changing unexpectedly (as you might if you were using the application's find/change method):

--FindChangeBullets.as 
--An InDesign CS AppleScript 
--Set myMakeExample to false to find/change text in 
--the active document, or set it to true to generate an 
--example document to demonstrate the script. 
set myMakeExample to true 
tell application "InDesign CS" 
	set find preferences to nothing 
	set change preferences to nothing 
	if myMakeExample = true then 
		set myString to "First paragraph. 
z	First bulleted paragraph. 
x	Second bulleted paragraph. 
z	Third bulleted paragraph. 
x	Fourth bulleted paragraph. 
x	Fifth bulleted paragraph. 
x	Sixth bulleted paragraph. 
x	Seventh another bulleted paragraph. 
z	Eighth bulleted paragraph. 
x	Ninth another bulleted paragraph. 
x	Tenth another bulleted paragraph. 
x	Eleventh another bulleted paragraph. 
x	Twelfth another bulleted paragraph. 
k	Thirteenth another bulleted paragraph." 
		set myDocument to make document 
		tell page 1 of myDocument 
			set myTextFrame to make text frame with properties {geometric bounds:{"6p", "6p", "36p", "36p"}, contents:myString} 
		end tell 
	else 
		set myDocument to active document 
	end if 
	tell myDocument 
		--There might be a way to do this with a filter clause, but I've had no luck constructing one. 
		repeat with myStoryCounter from 1 to (count stories) 
			repeat with myCounter from 1 to (count paragraphs of story myStoryCounter) 
				set myParagraph to object reference of paragraph myCounter of story myStoryCounter 
				set myCharacter to character 2 of myParagraph 
				set myContents to contents of character 2 of myParagraph 
				if contents of character 2 of myParagraph = "	" then 
					--Enter your bullet character (or the Unicode string for your bullet character) 
					--in the following line. 
					set contents of character 1 of myParagraph to "<2019>" 
				end if 
			end repeat 
		end repeat 
	end tell 
end tell

Thanks,

Ole
Technical Details
Message-ID: <2ccdefcd.5@webx.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!webx
References: <2ccdefcd.-1@webx.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f939a,31b95e11472f0fd8
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2003-11-07 12:38:00 PST
From: Olav_Kvern@adobeforums.com
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!webx
Newsgroups: adobe.scripting.indesign
Subject: Re: search with wildcards not working properly in AppleScript
Message-ID: <2ccdefcd.5@webx.la2eafNXanI>
Date: Fri, 7 Nov 2003 12:17:20 -0800
References: <2ccdefcd.-1@webx.la2eafNXanI>
Lines: 62
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit