Skip to main content
Inspiring
March 5, 2019
Answered

Find/Change by list script substitute fontStyle by character style

  • March 5, 2019
  • 1 reply
  • 2587 views

I'm trying to use the built-in find-change script by list to find fontStyle:"Italic" applied to any text and apply a character style to the found results. I've tried the 'RecordFindChange' script and tried to edit the search query in line with the examples, but to no avail.

I've also tried to find the reference that explains all possible find and change properties, but no success yet.

The query that I thought should work is below, but my CC 2017 returns the error number 25, expected: :

text    {fontStyle:"Italic"}    {appliedCharacterStyle:"Italic EN"}    {include footnotes:true, include master pages:true, include hidden layers:true, whole word:false}    comment

Thanks in advance for any help you can offer!

Titus

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

Manan, thanks for following up. I tested it as you did with a new simple test document, where it worked fine for me too. The reason I couldn't get it to work in the first place was that the style was organised within a folder, and apparently the script does not find it this way.

Many thanks for your help!

Titus


Hi Titus,

 

If you want to make it work with character styles nested inside groups then you can look at one of the other threads in which i solved this issue for paragraphStyles.

FindChangeByList—apply a paragraph tag that resides in a folder

 

In the post marked correct change paragraphstyle to character style and it should work for you, like below

appliedCharacterStyle:app.doScript('function getStyle(){var cs = app.activeDocument.allCharacterStyles;for(var i = 0; i < cs.length; i++){if( cs[i].name == "Italic EN" ) return cs[i]}}getStyle()', ScriptLanguage.javascript)}

 

Edit:Fixed the code issue which occured due to forum migration

-Manan

1 reply

Community Expert
March 5, 2019

use the following

text {fontStyle:"Italic"} {appliedCharacterStyle:"Italic EN"} {includefootnotes:true, includemasterpages:true, includehiddenlayers:true, wholeword:false}

notice the space you have between include footnotes and others is not needed this is what causes the error

-Manan

tntypeAuthor
Inspiring
March 5, 2019

Thank you for the quick reply!

Unfortunately it doesn't quite solve it yet, but returns a new error: number 30477, Invalid parameter.

Raphaël Freeman
Known Participant
March 6, 2019

The first one did work for me, the issue is that you need to double escape your string, try with the following

\\(\\d+:\\d+\\)

-Manan


I was literally just about to post a question and saw this thread. The solution was to double escape! Thank you so much!