Re: Changing CAPITAL to Upper And Lower Case
Re: Changing CAPITAL to Upper And Lower Case
- Subject: Re: Changing CAPITAL to Upper And Lower Case
- From: Hans Haesler <email@hidden>
- Date: Mon, 15 Jan 2007 00:06:37 +0100
On Fri, 12 Jan 2007, Ripka, Herb wrote:
>We have a book in QuarkXPress where the titles are all CAPITAL
>letters (and in style sheet "One").
>Is there a way in AppleScript where the titles (in style sheet
>"One") can be changed to Upper And Lower Case instead?
Herbert,
below is a script which needs the Scripting Addition
"Satimage.osax" for changing the Caps into lower case.
The script does the job the following way:
- It loops through the stories of the front XPress project.
- For each story it makes a list of the indexes of every
paragraph whose style sheet is "One".
- It loops through this list and changes the contents of the
paragraphs to lower case, except the first character
of every paragraph.
If a paragraph contains proper nouns, you must restore
the capital letters manually. The script can't do this.
It is way dumber than the chap who typed all of them capital
letters ;-). Please tell him (or her) that next time he
should type everything normally. And, if needed, set the
style of the style sheet to 'all caps'.
BTW, your subject line suggests that you'd like to convert
the text into *title case* (each word with a capital).
If this is true, then please come back.
To speed up execution, the view scale is set to 800 (trying
to avoid showing a text box. The window is reduced to a
minimal size. A script object is called to do the job.
When it has finished, the view scale and the size of the
window are restored.
To make the resizing work you must remind XPress that it
is able to do this: Before running the following script
please grab the lower right corner of the document window
and change the size a little bit. Note that this manual
action has to be done only _once_ for each "session"
with QuarkXPress.
Regards,
Hans
---
tell application "QuarkXPress 6.52"
activate
if (document 1 exists) then
tell document 1
set projName to name
set actView to view scale
set view scale to 800
end tell
tell project 1
tell active layout space
set layName to name
end tell
end tell
set winName to projName & " : " & layName
tell window winName
set {wx1, wy1, wx2, wy2} to bounds
set bounds to {wy1, wx1, 23, 23}
end tell
with timeout of 300 seconds
do script {toLower}
end timeout
tell document 1
set view scale to actView
end tell
tell window winName
set bounds to {wy1, wx1, wy2, wx2}
end tell
display dialog "Done." buttons "OK" default button 1 with icon 1 giving up after 1
else
display dialog "Open a document, please." buttons "OK" default button 1 with icon 2
end if
end tell
script toLower
global indexList
tell document 1 of application "QuarkXPress 6.52"
set selection to null
repeat with i from 1 to count of stories
tell story i
try
set indexList to (index of every paragraph whose name of style sheet is "One")
repeat with j from 1 to count of indexList
tell paragraph (item j of my indexList)
try
tell characters 2 thru -1
set contents to lowercase (it as string)
end tell
end try
end tell
end repeat
end try
end tell
end repeat
end tell
end script
---
_______________________________________________
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/mailman//archives/applescript-users
This email sent to email@hidden