I came across the following script to find and replace paragraph styles, which works perfect if the styles are sitting at the first level within the list of paragraph styles. The problem I having is that the document I’m working with has folders within folders of paragraph styles.
How can I update the following code to reference a paragraph style within folders? The style is placed in the following folder - Amended Styles > Body > Body Text half amended
set DeleteList to {"Body Text half"}
set ReplaceList to {"Body Text half amended"}
tell application "Adobe InDesign CS6"
activate
tell document 1
set MyStories to every story
repeat with StoryCount from 1 to (count of MyStories)
tell (item StoryCount of MyStories)
repeat with CurrentParagraph from 1 to count of paragraphs
set ParStyle to name of applied paragraph style of paragraph CurrentParagraph
if DeleteList contains ParStyle then
repeat with x from 1 to count of DeleteList
if item x of DeleteList is ParStyle then
set applied paragraph style of paragraph CurrentParagraph to item x of ReplaceList
end if
end repeat
end if
end repeat
end tell
end repeat
end tell
end tell
This is what I’ve tried so far but failed miserably
set DeleteList to {"Body Text half"}
set ReplaceList to {"Body Text half amended"}
tell application "Adobe InDesign CS6"
activate
tell document 1
set MyStories to every story
repeat with StoryCount from 1 to (count of MyStories)
tell (item StoryCount of MyStories)
repeat with CurrentParagraph from 1 to count of paragraphs
set ParStyle to name of applied paragraph style of paragraph CurrentParagraph
if DeleteList contains ParStyle then
repeat with x from 1 to count of DeleteList
if item x of DeleteList is ParStyle then
set StandardStyle to paragraph style item x of ReplaceList of paragraph style group "Body" of paragraph style group "Amended Styles" of document 1
set applied paragraph style of paragraph CurrentParagraph to StandardStyle
end if
end repeat
end if
end repeat
end tell
end repeat
end tell
end tell