Skip to main content
Barb Binder
Community Expert
Community Expert
December 10, 2022
Answered

Help with GREP syntax in FindChangeByList script

  • December 10, 2022
  • 8 replies
  • 842 views

Hi InDesign Friends:

 

Within a FindChangeByList script, I'm trying to target the paragraphs styled with Subhead 2 (A, B) that may have italics assigned via a character style called Italic. And I want to change the Italic character style within the Subhead 2 (A, B)s to a character style called Bold Italic.

 

This is what I have, but it's not working:

grep {appliedParagraphStyle:"Subhead 2 (A, B)", appliedCharacterStyle:"Italic"} {appliedCharacterStyle:"Bold Italic"} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}
 
Subhead 2 (A, B) is in a style group called Subheads
  • Do I need to reference the group and the style name?
  • Or are the parentheses in the style name an issue?
  • Or am just entirely off track?
 
Thanks in advance, 
~Barb

 

This topic has been closed for replies.
Correct answer Manan Joshi

Hi @Barb Binder,

Based on our older discussion on how to access styles from folders in FindChangeByList, link given below

https://community.adobe.com/t5/indesign-discussions/findchangebylist-apply-a-paragraph-tag-that-resides-in-a-folder/td-p/10139539

The following string worked for me

 

grep	{appliedParagraphStyle:app.doScript('function getStyle(){var ps = app.activeDocument.allParagraphStyles;for(var i = 0; i < ps.length; i++){if( ps[i].name == "Subhead 2 (A, B)" ) return ps[i]}}getStyle()', ScriptLanguage.javascript), appliedCharacterStyle:"Italic"}	{appliedCharacterStyle:"Bold Italic"}	{includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}

 

Change the spaces to tabs, you know the drill by now. Let me know if you see any issues

P.S.:- This searches for the style irrespective of whether its in a group or not. The search is not robust to check that the style path i.e. folder and name both matches. This string should suffice in cases where the style is uniquely named in the document. If you need more robust search that can also be done, let me know if that is needed.

-Manan

8 replies

Barb Binder
Community Expert
Community Expert
December 12, 2022

Hi @Manan Joshi:

 

When it wasn't an easy answer, I suspected it would eventually come down to you and me again, it took all my willpower not to tag you! 😂

 

So thank you for this. You are right, of course, that this syntax does appear further down my FCBL text file—it's been growing over the years and I was basing this a simpler query. I didn't even look down at the bottom of the file or maybe I would have had a chance. I am going to add some notes so that maybe, just maybe, I can do this on my own someday.

 

So once again, I thank you from the bottom of my heart. I learn a little more each time we chat, but boy do I have a long way to go!

 

~Barb

~Barb at Rocky Mountain Training
Mike Witherell
Community Expert
Community Expert
December 12, 2022

Hey Barb, I recently started using this:

http://kasyan.ho.ua/indesign/text/record_find_change/record_find_change.html

Thought I would mention it in case it helps.

Mike Witherell
Barb Binder
Community Expert
Community Expert
December 12, 2022

Wow, Mike, looks great. But I'm afraid @Manan Joshi would miss me! 😂 Just in case he's ready to be done with me, though, I downloaded it. Thanks!

 

~Barb

~Barb at Rocky Mountain Training
Manan JoshiCommunity ExpertCorrect answer
Community Expert
December 12, 2022

Hi @Barb Binder,

Based on our older discussion on how to access styles from folders in FindChangeByList, link given below

https://community.adobe.com/t5/indesign-discussions/findchangebylist-apply-a-paragraph-tag-that-resides-in-a-folder/td-p/10139539

The following string worked for me

 

grep	{appliedParagraphStyle:app.doScript('function getStyle(){var ps = app.activeDocument.allParagraphStyles;for(var i = 0; i < ps.length; i++){if( ps[i].name == "Subhead 2 (A, B)" ) return ps[i]}}getStyle()', ScriptLanguage.javascript), appliedCharacterStyle:"Italic"}	{appliedCharacterStyle:"Bold Italic"}	{includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}

 

Change the spaces to tabs, you know the drill by now. Let me know if you see any issues

P.S.:- This searches for the style irrespective of whether its in a group or not. The search is not robust to check that the style path i.e. folder and name both matches. This string should suffice in cases where the style is uniquely named in the document. If you need more robust search that can also be done, let me know if that is needed.

-Manan

-Manan
Barb Binder
Community Expert
Community Expert
December 11, 2022

Robert, does all of that follow GREP { in the FCBL script? It's still not working for me and I'm out of my depth to troubleshoot it.

 

I can always run 1 F/C after the script. This works as expected. I had some downtime and was trying to get it into the FCBL script.

 

~Barb

 

~Barb at Rocky Mountain Training
Barb Binder
Community Expert
Community Expert
December 11, 2022

Hi Robert, thank you for trying to help. I'm away from my computer until tomorrow. I'll be back once I have time to test this out. 

~Barb

~Barb at Rocky Mountain Training
Robert at ID-Tasker
Legend
December 10, 2022

https://community.adobe.com/t5/indesign-discussions/findchangebylist-script/td-p/1868007/page/2

 

Kasyan's reply:

 

I tested the syntax and it works:

 

appliedParagraphStyle:app.activeDocument.paragraphStyleGroups.item("Style Group 1"). paragraphStyles.item("Endnotes Head")

 

just write the name of your style group instead of "Style Group 1"

 

Barb Binder
Community Expert
Community Expert
December 10, 2022

Again, thank you, @Peter Spier. I've double-checked the spelling. Maybe the group name needs to be added?

 

~Barb

~Barb at Rocky Mountain Training
Peter Spier
Community Expert
Community Expert
December 10, 2022

I'm not sure you can use the script to access styles in folders.

We need to hear from someone more expert than I.

Barb Binder
Community Expert
Community Expert
December 10, 2022

Thank you @Peter Spier. I tried that earlier but assuming user error I tried it again, but still not working:

grep	{appliedParagraphStyle:"Subhead 2 \(A, B\)", appliedCharacterStyle:"Italic"}	{appliedCharacterStyle:"Bold Italic"}	{includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}

 

~Barb

~Barb at Rocky Mountain Training
Peter Spier
Community Expert
Community Expert
December 10, 2022

Sure there's a space in Subhead 2?

Peter Spier
Community Expert
Community Expert
December 10, 2022

I think you'll need to "escape" the parentheses (add a \before each one).