Pages app - If first char is bold, prepend period. X becomes .X

In a 600 pg Pages doc I need to find all lines where first char is bold and prepend a period before the bold char.

Thus bold “A” becomes “.A” etc… Bold “B” becomes “.B” etc.

Which Pages version are you running ?
The late 5.0.1 one is no longer a tool but a toy with a very poor AppleScript support.

If you are running Pages 4.x, which is the format in use : Word Processing or Page Layout.

If you are using Word Processing in Pages 4.x, here is a script doing the job.

tell application "Pages" to tell document 1 to tell body text
	repeat with aParagraph in every paragraph
		if bold of first character of aParagraph is true then
			set first character of aParagraph to ("." & first character of aParagraph)
		end if
	end repeat
end tell

I’m quite sure that there is a more efficient scheme using a whose clause.

Yvan KOENIG (VALLAURIS, France) lundi 13 janvier 2014 17:10:45

My apologies… I should have mentioned that. The new one is such junk I have forced myself to forget that it exists. I’m running the the old one from iWork 09. (Pages 4.3)

The script posted above does the job.

I tried with :

tell application "Pages" to tell document 1 to tell body text
	repeat with aParagraph in (every paragraph whose bold of first character is true)
		set first character of aParagraph to ("." & first character of aParagraph)
	end repeat
end tell

but it failed with :
error “Erreur dans Pages : Le gestionnaire AppleEvent a échoué.” number -10000

Yvan KOENIG (VALLAURIS, France) lundi 13 janvier 2014 17:31:49

Perfect! Thank you for your time and expertise!

I work with pages daily doing eBooks, documents, etc (paid job) and I really need to learn scripting specifically as it applies to Pages. Is there a good resource that you know of the deals specifically with Pages scripting? I did check resources section but saw nothing that specific (Pages).

You may download a lot of scripts from :

http://www.adrive.com/public/PgkZNE/for_Numbers09.zip

http://www.adrive.com/public/a7t26v/for_Pages09.zip

[url=http://www.adrive.com/public/SPPR3X/other_iWork09]http://www.adrive.com/public/SPPR3X/other_iWork’09[/url] items.zip

To make them available quickly I just zipped folders embedding already zipped items.

These links will expire on : 2014-01-28

These scripts were written before Mavericks and many of them before Mountain Lion so they may fail.
In such case, warn me at :
koenig yvan sfr fr

Most of the time updating them would be easy but I have more useful tasks to fill than scanning all the scripts.
Some of them ” grabbing datas in resources ” require also changes because I wrote the scripts when iWork was delivered as a single package. In this case, the three embedded applications shared resources stored in :
Macintosh HD:Library:Application Support:iWork '09:Frameworks:

Applications sold separately on Mac App Store embed a copy of the Frameworks folder in their own package.

Have fun.

Yvan KOENIG (VALLAURIS, France) mardi 14 janvier 2014 10:09:38

Thank you very much! Above and beyond expectations.