I’ve written an applescript that will go through an InDesign CS selection and apply styles to the various paragraphs depending on specific criteria. One criteria to apply a “Nested Paragraph Style” is to find a colon in the first line of the selected paragraph. But I can’t seem to make it work. This is the script that I’ve written: (the part I can’t get to work is the line that says “if line 1 contains “:” then…” If I substitute a specific word for the colon it will work. But right now it’s setting the style of every paragraph to “nesting” even though there aren’t any colons in the paragraph. Is there an “escape” character that I need to put before and after the colon? I’ve searched everywhere for an answer but haven’t found anything.
Thanks for whatever help you can give.
Art Joyce
tell application "InDesign CS"
activate
tell document 1
set theParaStyle to paragraph style "Paragraph Body"
set mainHead to paragraph style "Main Headings"
set nesting to paragraph style "Nested paragraph"
set myselection to selection
set myParagraphs to (count of paragraphs of selection)
repeat with x from 1 to myParagraphs
tell paragraph x of selection
if paragraph style is not theParaStyle then
set applied paragraph style to theParaStyle
if line 1 contains ": " then
set applied paragraph style to nesting
end if
if (count of characters) < 30 then
set applied paragraph style to mainHead
end if
end if
end tell
end repeat
end tell
end tell
Model: PowerBook G4
AppleScript: 1.10.6
Browser: Safari 417.9.3
Operating System: Mac OS X (10.4)