Is there a quick and/or easy way in Applescript to make text all caps? Right now, I have a script that does formats and manipulates text in an InDesign document. What I need to do now is grab some text and make it upper case. I have that text in a variable in my script, so if it’s possible in just AppleScript–great. Also, if anyone knows how to do this in InDesign, I could do it that way as well. I end up just exporting all the text from InDesign. I’m using InDesign CS 3.0.1. Thanks for any help
Use the changecase command.
– Shane Stanley
That’ll do it. Thanks a ton!
try
set clipboart_text to the clipboard as string
on error
display dialog “Please, copy to the clipboard some text to processing…” buttons {“Oops…”} ¬
default button 1 with icon caution
return
end try
set action_type to button returned of ¬
(display dialog “Please, choose the type of text conversion…” buttons {““UPPER” case”, ““lower” case”, “Cancel”} ¬
default button 3 with icon 1)
if action_type is “Cancel” then ¬
return
set converted_text to {}
repeat with i from 1 to length of clipboart_text
set current_character to character i of clipboart_text
set current_ASCII to ASCII number of current_character
set converted_character to current_character
if current_ASCII >= 128 and ¬
current_ASCII <= 159 or ¬
current_ASCII is in {221, 216, 184} then -- UPPER cyrillic letters
-- convert each character if need conversion
if action_type is ""lower" case" then
if current_ASCII is in {221, 216, 184} then
set converted_character to ASCII character (current_ASCII + 1)
else
set converted_character to ASCII character (current_ASCII + 96)
end if
end if
else if current_ASCII >= 224 and ¬
current_ASCII <= 254 or ¬
current_ASCII is in {223, 222, 217, 185} then -- LOWER cyrillic letters
-- convert each character if need conversion
if action_type is ""UPPER" case" then
if current_ASCII is 223 then
set converted_character to ASCII character 159
else if current_ASCII is in {222, 217, 185} then
set converted_character to ASCII character (current_ASCII - 1)
else
set converted_character to ASCII character (current_ASCII - 96)
end if
end if
else if current_ASCII >= 65 and ¬
current_ASCII <= 90 then -- UPPER latin letters
-- convert each character if need conversion
if action_type is ""lower" case" then ¬
set converted_character to ASCII character (current_ASCII + 32)
else if current_ASCII >= 97 and ¬
current_ASCII <= 122 then -- LOWER latin letters
-- convert each character if need conversion
if action_type is ""UPPER" case" then ¬
set converted_character to ASCII character (current_ASCII - 32)
end if
set end of converted_text to converted_character
end repeat
set converted_text to converted_text as string
set the clipboard to converted_text
beep
say “Finished conversion. Enjoy”
P.S. I make this script year ago for correct conversion Cyrillic letters.