Skip to main content
Known Participant
December 8, 2023
Question

export all grep styles applied in a paragraph

  • December 8, 2023
  • 4 replies
  • 857 views

I have many grep styles in a given paragraph. Is there a script where I can export grep styles as text? It would be much nicer if I could import grep styles after editing. (It is very difficult to make grep styles from the grep styles menu)

Thank you very much for your help.

This topic has been closed for replies.

4 replies

Joel Cherney
Community Expert
Community Expert
December 10, 2023

Like Eugene, I'm trying to imagine why you'd want to do this. No matter why you'd want to extract all GREP Styles as a CSV, it's possible to automate the process with Javascript. There are a few ways to go about it, but the core of it would rely on something like this:

app.activeDocument.paragraphStyles.itemByName("putYourStyleNameHere").nestedGrepStyles[0].grepExpression;

This is just from my brief experimentation; to turn it into working code, I'd need to loop through all parastyles, and then while processing each parastyle, loop through all the nestedGrepStyles.

 

But if I were in your shoes, I'd use a very different approach. I'd do the extraction one regex at a time, and I'd just use AutoHotkey to automate the process of copying a single regex out of the Paragraph Style dialog, pasting it into My Preferred Raw Text Editor, and I'd write a second script to automate pasting it back in. This is mostly because I have found that I like to see the immediate effects of an altered regular expression, and the idea that I'd need to reimport a whole document's worth of regular expressions all at once doesn't really fill me with confidence. If you make a mistake in a regex, how do you find the responsible expression? Seems a little awkward, to me, but I'm sure you have your reasons. 

Robert at ID-Tasker
Legend
December 10, 2023

Thanks for the great idea @Joel Cherney.

 

Robert at ID-Tasker
Legend
December 8, 2023

PC or Mac?

 

Barb Binder
Community Expert
Community Expert
December 8, 2023

Hi @uniq1:

 

There is a script from @Kasyan Servetsky that should do it.

 

Here is a link: http://kasyan.ho.ua/indesign/export/export_styles_description_settings_to_csv.html. I know it says CS3–CC 2014 but he is still active on the forums so if there is a new version, he may be able to stop by and provide a link. In the meantime, it can't hurt to try it. 

 

~Barb

~Barb at Rocky Mountain Training
Community Expert
December 8, 2023

And does that import them again? 

Community Expert
December 8, 2023

If you have them as paragraph styles - you can use the Paragraph Panel to Load Styles - and then load the styels from any other document.

 

These styles contain the GREP codes you need. 

 

 

uniq1Author
Known Participant
December 8, 2023

@Eugene Tyson  Thanks.. but... 

I want to export or import Grep Codes as csv.

Community Expert
December 8, 2023

Why? I don't get it. 
How will you know which one to use? 

 

Can you explain a bit more?