Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

"macro" find&replace for Pages

+PAX


Greetings all! I'm in Lithuania. I've searched for a while about this, and can't seem to find much useful information to help me out.

I've got a ton of documents with Lithuanian characters: ą, č, ę, ė, į, š, ų, ū, ž and their capitals. The problem is that these documents were made with a homegrown font. How the font was constructed was by replacing not-so-frequently used characters with the Lithuanian ones. This results in the preceding list giving this: ı, ˝, ˆ, Ø, ˜, ˛, ¯, •, ˇ.


I've tried using the automator and appleScript to do a find & replace for Pages, so I can just click, and change all the letters from these coded ones, to their standard unicode positions. I can't figure out how to do it. There's no find or replace in the AppleScript dictionary for Pages.


Can anyone help?

Many thanks!!

MacBook Pro, OS X Mountain Lion (10.8.4), 2,8 GHz i7, 4 GB DDR3

Posted on Aug 10, 2013 2:46 AM

Reply
14 replies

Aug 10, 2013 7:13 AM in response to rminot

+PAX

Greetings again. Many thanks for both of your suggestions.

@Tom: I didn't think of that all! Yet, due to the quantity and columns, etc, I can't see that as a viable option.


@Peter: I've seen those listed on some other similar posts. Due to the content, I didn't think it would work for what I need. Guess I'll have to check them out now. At the moment, all three of those things are completely foreign to me: Grep, BBEdit, and nisus.


Most of the original docs, if not all, were created in QuarkXPress. I hate that program just as much as windows, and for the same reasons. The conversion doesn't need to take place in pages. It's still mind-boggling to me that something like this is so complicated on a Mac. It's got to be the only thing that you need a doctorate to accomplish on a Mac! Such is life.


In the meantime, I'm certainly open to any other suggestions!

Many many thanks.

Aug 10, 2013 8:57 AM in response to Tom Gewecke

I couldn't agree with you more about the homegrown font thing and loosing data forever. This is why we're in the situation that we're in.


There are several fonts. The principal one used is called Capella.

The monk who developed/modified the fonts did, however, do something intelligent. The same characters were always used. So the NULL symbol always produces the same Lithuanian character.


Even with the meta font which he modified, he did the same thing. Same characters were replaced with the same Lithuanian ones. This is why I am really in need of making some kind of script. It's near impossible to use the documents he created. Most everyone else is using Linux. I can use the files, but can't copy and paste text, because if the font is changed, then it's illegible. And plus, we have a brother who's loosing his eyesight. The screen-reader won't read the documents correctly.

Aug 10, 2013 12:41 PM in response to rminot

OCR would be impractical in this situation. It is not that accurate with regular text, to pick up the subtleties of accented characters would be considerably less accurate, and I strongly doubt there is a Lithuanian version. Maybe on Windows, definitely not on Mac.


You may not like Quark but it is highly AppleScriptable, however if you have an older version, not Unicode.


Also when AppleScript doesn't have a library item for a function you can use it to just simulate mouse selections and clicks.


BBedit


TextWrangler [free]


NisusWriter Pro


NisusWriter Express


GREP


Download WebScrub for Mac - Tool for preparing text for the internet. MacUpdate.com


Download Clean Text for Mac - Clean text docs with random spaces or line breaks. MacUpdate.com


Download Text Cleaner for Mac - Auto-cleans text documents. MacUpdate.com


Peter

Aug 11, 2013 8:47 AM in response to PeterBreis0807

+PAX


I've hit the jackpot! Well, at least it looks that way. First, many thanks for your help and interest!!

@Peter: I agree. Am also fascinated by OCR software for what you mention and so much more!

@Tom: thanks for the link to that other discussion. I don't seem to be a genius when it comes to finding stuff on the internet. But perhpas for once, I hit something good!!


I don't remember what I googled... but at macscripter.net, I came across this script:

tell application "Pages"

set toFind to"good"

set toReplace to"bad"

set theText to contents of document 1

set astid to AppleScript's text item delimiters

set AppleScript's text item delimiters to toFind

set textItems to theText's text items

set AppleScript's text item delimiters to toReplace

tell textItems toset editedText tobeginning & toReplace & rest

set AppleScript's text item delimiters to astid

set text of document 1 to editedText

endtell


You know what, IT WORKS!!! So what I did was copy and paste this same script for each item I need to replace. Just the Lithuanian letters are 18, normal case and capitals. When I tried a longer text, I discovered that there is much much more that needs to be added. The reasons is due to how the font was designed and certainly not in the scope of this post.


Now, why on Earth is not possible to have found this information somewhere from Apple?? Perhaps we'll never know. But at any rate, I can confirm that that this script will allow an automated find and replace all in Pages'09.


Next task: getting the script to be accessible from a menu item.

God bless!!

"macro" find&replace for Pages

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