Copy link to clipboard
Copied
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
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].
...Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Thank you for the quick reply!
Unfortunately it doesn't quite solve it yet, but returns a new error: number 30477, Invalid parameter.
Copy link to clipboard
Copied
Works for me. Make sure to replace the space to tabs as instructed in the FindChangeList.txt regarding the string format, forum copy paste messes it. Have a look below at things working for me using this same string
-Manan
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Fabulous, many thanks Manan!
Copy link to clipboard
Copied
Just following up on this with a slight modification. From what I can gather, the same script does not work for GREP queries and replacements, is that correct?
I've tried to figure it out myself using this:
https://www.indesignjs.de/extendscriptAPI/indesign10/#ChangeGrepPreference.html
But I can't see any differences between GREP and Text preferences.
I've tried these queries:
grep {findWhat:"\(\d+:\d+\)"} {appliedCharacterStyle:app.doScript('function getStyle(){var cs = app.activeDocument.allCharacterStyles;for(var i = 0; i < cs.length; i++){if( cs.name == "Quranic verse reference EN" ) return cs}}getStyle()', ScriptLanguage.javascript)} {includefootnotes:true, includemasterpages:true, includehiddenlayers:true, wholeword:false}
grep {findWhat:"^\d+\.\t"} {appliedParagraphStyle:app.doScript('function getStyle(){var ps = app.activeDocument.allParagraphStyles;for(var i = 0; i < ps.length; i++){if( ps.name == "P1 no indent EN" ) return ps}}getStyle()', ScriptLanguage.javascript)} {includefootnotes:true, includemasterpages:true, includehiddenlayers:true, wholeword:false}
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Double escape! Thank you so much, I'm learning...
Copy link to clipboard
Copied
I was literally just about to post a question and saw this thread. The solution was to double escape! Thank you so much!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now