Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Applescript/js find/change problem (x-post from InDesign forum)

New Here ,
Dec 14, 2011 Dec 14, 2011

I have some text which needs to be styled in InDesign CS4 which has a bunch of extraneous tags ( eg. <b>, <i>, etc.). I have customised the FindChangeList.txt file that supports the FindChangeByList.applescript file to do things like:

{find what:"<i>"}{change to:"^S"}

which can then be picked up by a nested style. All good so far.

Problem: the applescript/js will just not 'see' the strings <b> or </b> in FindChangeList.txt. It treats them like they aren't there. I can do it using the find/replace within InDesign, it works fine there, but my problem is that I have hundreds of pieces of copy to import and I'd like to automate as much as possible. Using GREP has the same effect, ie. works in find/replace within InDesign, but not with applescript.

Any help would be greatly appreciated as this is really killing me at the moment. Thanks!

Content of FindChangeList.txt follows. The command in the final line works, the command in the second-last line doesn't.

(FYI the second line of code contains 'InDesign CS3' regardless of whether I use CS3 or CS4. I guess they didn't update the file)

--FindChangeList.txt

--A support file for the InDesign CS3 AppleScript FindChangeByList.applescript

--

--This data file is tab-delimited, with carriage returns separating records.

--

--The format of each record in the file is:

--findType<tab>findProperties<tab>changeProperties<tab>findChangeOptio ns<tab>description

--

--Where:

--<tab> is a tab character

--findType is "text", "grep", or "glyph" (this sets the type of find/change operation to use).

--findProperties is a properties record (as text) of the find preferences.

--changeProperties is a properties record (as text) of the change preferences.

--findChangeOptions is a properties record (as text) of the find/change options.

--description is a description of the find/change operation

--

--Very simple example:

--text          {find what:"--"}          {change to:"^_"}          {include footnotes:true, include master pages:true, include hidden layers:true, whole word:false}          Find all double dashes and replace with an em dash.

--

--More complex example:

--text          {find what:"^9^9.^9^9"}          {applied character style:"price"}          {include footnotes:true, include master pages:true, include hidden layers:true, whole word:false}          Find $10.00 to $99.99 and apply the character style "price".

--

--All InDesign search metacharacters are allowed in the "find what" and "change to" properties.

text          {find what:"<b>"}          {change to:"^S"}          {include footnotes:true, include master pages:true, include hidden layers:true, whole word:false}          Find all bold and replace with non-breaking space.

text {find what:"<i>"} {change to:"^S"} {include footnotes:true, include master pages:true, include hidden layers:true, whole word:false} Find all italics and replace with non-breaking space.

TOPICS
Scripting
2.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 14, 2011 Dec 14, 2011

...and just while I'm at it, if anyone knows how to specify styles within these applescript/js files, then I will order you a pizza right now!

eg. find "string" in character/paragraph style x, change to "other-string" in character/paragraph style y

I'm not kidding about that pizza, by the way.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 15, 2011 Dec 15, 2011

See my post over in the ID forum

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 15, 2011 Dec 15, 2011

It looks like you are trying to style the text between the HTML tags and then strip them right? Make a character style named "bold" and try this (I posted a table so you can cut and paste and keep the tabs):

grep{find what:"(?<=<b>).*?(?=</b>)"}{applied character style:"bold"}{include footnotes:true, include master pages:true, include hidden layers:true, whole word:false}
text{find what:"<b>"}{change to:"^S"}{include footnotes:true, include master pages:true, include hidden layers:true, whole word:false}
text{find what:"</b>"}{change to:"^S"}{include footnotes:true, include master pages:true, include hidden layers:true, whole word:false}
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 15, 2011 Dec 15, 2011

Thanks for this Rob, and for your other comment in the ID forum. I realised there was probably some error in the old find/replace file, so started putting it back together, line by line, in order to make sure it worked each step of the way. Although, for some reason, I thought it would better to try in JS as I was a bit gun-shy from applescript. For some reason the JS seems to be choking on the GREP expression {find what:"(?<=<b>).*?(?=</b>)"}, even though there's other GREP expressions in my code. I'll have a look around and see if I can work this out, but if you have any tips, I'd be most grateful. Also, I presume there's no way you know of to do:

find "string" in character/paragraph style x, change to "other-string" in character/paragraph style y

Thanks again for your help.

L

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 16, 2011 Dec 16, 2011

find "string" in character/paragraph style x, change to "other-string" in character/paragraph style y

There isn't a way to do it with the free text script, but you could do inside a script by looping through every paragraph, testing for the name then running your find and change sequence.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 18, 2011 Dec 18, 2011
LATEST

Thanks for your help with this Rob, much appreciated.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines