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

FindChangeByList script

New Here ,
Apr 30, 2009 Apr 30, 2009

Copy link to clipboard

Copied

I'm trying to use this pre-made script in CS4, and I customized the accompanying .txt file with all our Find-and Replace needs, but when I actually try to the run the script on a document, the following error message comes up:

Error Number: 23

Error String: does not have a value

File: [name and location of jsx file follows]

Line: 159

Source: app.doScript(myString, ScriptLanguage.javascript);

Anyone know how to get past this? It's very hard to see what Line 159 in the script file has to do with anything.

Thanks.

TOPICS
Scripting

Views

24.4K

Translate

Translate

Report

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
Advocate ,
Apr 30, 2009 Apr 30, 2009

Copy link to clipboard

Copied

Hi David,

That error indicates that there is an error in the script in myString which the script you're running has assembled (from the information in your customized .txt file).

Can you tell if any of your searches were executed? That would give a clue as to how far the script progressed before hitting the error.

Alternatively, post your .txt file here and let us see if we can help.

Dave

Votes

Translate

Translate

Report

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 ,
Apr 30, 2009 Apr 30, 2009

Copy link to clipboard

Copied

Thanks. No changes were made. Here is the contents of the text file.

//FindChangeList.txt
//Data file for use with the FindChangeByList.jsx script for InCopy CS4.
//
//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>findChangeOptions<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    {findWhat:"--"}    {changeTo:"^_"}    {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}    Find all double dashes and replace with an em dash.
//
//More complex example:
//text    {findWhat:"^9^9.^9^9"}    {appliedCharacterStyle:"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 InCopy search metacharacters are allowed in the "findWhat" and "changeTo" properties.
//
grep    {findWhat:"  +"}    {changeTo:" "}    {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}    Find all double spaces and replace with single spaces.
grep    {findWhat:"\r "}    {changeTo:"\r"}    {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}    Find all returns followed by a space And replace with single returns.
grep    {findWhat:" \r"}    {changeTo:"\r"}    {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}    Find all returns followed by a space and replace with single returns.
text    {findWhat:" - "}    {changeTo:"^="}    {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}    Find all space-dash-space and replace with an en dash.
text    {findWhat:"--"}        {changeTo:"^_"}    {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}    Find all dash-dash and replace with an em dash.
text    {findWhat:" -- "}    {changeTo:"^_"}    {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}    Find all space dash-dash space and replace with an em dash.
text    {findWhat:" ^_ "}    {changeTo:"^_"}    {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}    Find all space em dash space and replace with an em dash.
text    {findWhat:"0^]s"}    {changeTo:"0s"}    {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}    Find all 0 apostrophe s and replace with 0s.
text    {findWhat:"^e"}        {changeTo:".^<.^<."}    {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}    Find all ellipses and replace with consecutive period thin space thin spaces.

Votes

Translate

Translate

Report

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
Guru ,
Apr 30, 2009 Apr 30, 2009

Copy link to clipboard

Copied

Here is a working version, I tested it on CS3 for PC, hope it works on CS4 as well.

http://www.kasyan.ho.com.ua/downloads/FindChangeList.txt

P.S. Make sure to download it – don't copy-paste

Kasyan

Votes

Translate

Translate

Report

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
Guest
May 06, 2009 May 06, 2009

Copy link to clipboard

Copied

Hi,

This is exactly I am looking for, a simple find/replace script but when I try to run your script it has a problem with the very first curly bracket right after the word 'grep'...it says at the left bottom: 'Expected: ;'

It is driving me crazy, I am not familiar with script writing and I have no clue what is wrong. Any idea?

Thank you!

Votes

Translate

Translate

Report

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
Guru ,
May 06, 2009 May 06, 2009

Copy link to clipboard

Copied

This script is not my, but pre-installed with InDesign. Most probably there's some error in FindChangeList.txt file that accompanies the script. Have you changed it?

Yesterday I wrote my own script which saves queries and then runs them in sequence. There is no need to meddle with FindChangeList.txt, finding out how to write correct settings. I am going to post it on my site if anybody is interested. But so far it is not completely tested and supports only text search-replace operations.

Kasyan

Votes

Translate

Translate

Report

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
Guest
May 06, 2009 May 06, 2009

Copy link to clipboard

Copied

I tried the script found here, I tried the one comes with ID (I haven't changed it)...none of them works. I found an other topic where someone had the same issue and Olav replied and suspected it was something to do with CS4 (I'm using ID CS4, Windows XP) but then it went private.

I have to do lots of find/replace and GREP all the time and thought a script would save me time so I would be definitely interested the script you have written, I might find some useful things in it which will help to write mine.

Thanks.  

Votes

Translate

Translate

Report

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
Guru ,
May 06, 2009 May 06, 2009

Copy link to clipboard

Copied

I'll post it later – may be tomorrow morning.

Votes

Translate

Translate

Report

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
Guest
May 06, 2009 May 06, 2009

Copy link to clipboard

Copied

Fabulous!

Votes

Translate

Translate

Report

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
Explorer ,
May 06, 2009 May 06, 2009

Copy link to clipboard

Copied

Hey man,

I had something similar recently and it turned out to be a sligh 'space' in the middle of the 'tabs' needed to seperate the values in the acutal list.

Not sure if you have the same problem, but might be worth checking anyway.

Adios!

Votes

Translate

Translate

Report

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
Guru ,
May 06, 2009 May 06, 2009

Copy link to clipboard

Copied

What search-replace operations do you want to perform? Describe what you type manually into Find/Change dialog. Or make screenshots and send them to me – I'll test it when time permits.

Votes

Translate

Translate

Report

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
Guest
May 06, 2009 May 06, 2009

Copy link to clipboard

Copied

Find and Replace text would be for example:

<\#165><\#9>           change to: <0x2022>^t

and a GREP:

(<B>)(.+?)(<B>)            change to: <ct:65 Bold>$2<ct:>

I use Find and Replace and GREP to convert textfiles for Quark into textfiles for InDesign hence a script that does it with one click would be awsome! So if I had a basic script that I can extend it would be more than appreciated...

Votes

Translate

Translate

Report

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
Guest
May 06, 2009 May 06, 2009

Copy link to clipboard

Copied

Hi aevee,

Something like this:

//Clear find/change text preferences
app.findTextPreferences = NothingEnum.nothing;
app.changeTextPreferences = NothingEnum.nothing;
//Set up the find/change strings (note "escaped" backslash characters).
app.findTextPreferences.findWhat = "<\\#165><\\#9>";
app.changeTextPreferences.changeTo = "<0x2022>^t";
//Change the text.
app.documents.item(0).changeText();
//Clear find/change text preferences.
app.findTextPreferences = NothingEnum.nothing;
app.changeTextPreferences = NothingEnum.nothing;
//Clear find/change grep preferences.
app.findGrepPreferences = NothingEnum.nothing;
app.changeGrepPreferences = NothingEnum.nothing;
//Set up the grep find/change
app.findGrepPreferences.findWhat = "(<B>)(.+?)(<B>)";
app.changeGrepPreferences.changeTo = "<ct:65 Bold>$2<ct:>";
//Change the text.
app.documents.item(0).changeGrep();
app.findGrepPreferences = NothingEnum.nothing;
app.changeGrepPreferences = NothingEnum.nothing;


Thanks,

Ole

Votes

Translate

Translate

Report

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
Guest
May 07, 2009 May 07, 2009

Copy link to clipboard

Copied

Fantastic! Thank you ever so much Olav! You've made my day...

And a very last question...if I have a list of GREPs let's say, do I have to 'clear find/change grep preferences' first every time before setting up a new one?

Thank you again!!!!!!!!!!

Votes

Translate

Translate

Report

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
Guru ,
May 07, 2009 May 07, 2009

Copy link to clipboard

Copied

Aevee, here is the script I promised:

http://www.kasyan.ho.com.ua/find_change_by_queries.html

Votes

Translate

Translate

Report

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
Guest
May 07, 2009 May 07, 2009

Copy link to clipboard

Copied

Splendid! Very clever. Exactly what I needed to control the formats as well...

Thank you, thank you, thank you Kasyan! 

Votes

Translate

Translate

Report

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
Guru ,
May 07, 2009 May 07, 2009

Copy link to clipboard

Copied

I wrote it the day before yesterday, so it's not thoroughly tested yet. Let me know how it works. BTW, I am open to any suggestions as to how improve it.

Votes

Translate

Translate

Report

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
Guest
May 07, 2009 May 07, 2009

Copy link to clipboard

Copied

I followed your instructions and it worked fine.

What I really like about it that you can change it very easily by deleting/renaming/rearranging the textfiles the script creates instead of going through a whole long script amending it all the time. I haven't tried yet but I guess you can create lots of different  'Queries' by renaming the folders. Genius!  If it supports GREP as well it will be extremely useful for many of us I believe (it already is but then....can't wait!).

Thank you again!

Votes

Translate

Translate

Report

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
Contributor ,
Aug 11, 2009 Aug 11, 2009

Copy link to clipboard

Copied

WOW!!! I have been having lots of problems with this script (see CS4: Can't find and replace returns ) and then I found this script... and it works!!! This is a dream come true!!! And it also works lightning fast!!! Thanks, Kasyan, you really made my day!!! Now I can find and replace everything I want everytime I want to without any problems at all! And I can add new queries whenever I come across new ones. Absolutely great. (GREP support would be nice indeed, but for now I simpy repeat the script until nothing gets changed anymore.)

AWESOME!

Votes

Translate

Translate

Report

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 Beginner ,
Aug 11, 2009 Aug 11, 2009

Copy link to clipboard

Copied

J van E

If you want GREP searches too, use the script Kasyan offers in post 38

It captures any Find/Change you do in ID and all you have to do then is copy and paste it in the regular FindChangebyList txt file

That's what I ended up doing, I think it's simpler and more robust and of course it allows you to do GREP searches

A single text file and the regular (CS4) findchangebylist.jsx file runs about a hundred sundry searches for us in a single pass

Outstanding, all praise to Kasyan

Votes

Translate

Translate

Report

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
Contributor ,
Aug 11, 2009 Aug 11, 2009

Copy link to clipboard

Copied

To tell you the truth, I tried that other script, but it didn't do anything... Well, I get a message saying Done, but I can't find a file or anything with the lines of script in it... So I ended up using that other script. Maybe I am doing something wrong?

BTW I solved the problems of not being able to find repetition of spaces and tabs and so on (which is the only reason for using GREP right now) by simply copying the saved queries. So now I've got (for instance) 5 queries that looks for two tabs and replaces it by one and I don't have to rerun the script a few times: all is done with one press.

Votes

Translate

Translate

Report

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 Beginner ,
Aug 11, 2009 Aug 11, 2009

Copy link to clipboard

Copied

I had the same problem early on

You have to do it in the sequence it says to

And the pop up window it generates with the captured text sometime gets behind other windows first time around, when it says Done, hide other windows until you find it

Votes

Translate

Translate

Report

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
Contributor ,
Aug 11, 2009 Aug 11, 2009

Copy link to clipboard

Copied

Er. well, the problem is it doesn't tell my anything about a sequence and I didn't see an instruction for this script as there is for the other... What is the right sequence? When I simply run the script, I immediately get the Done message and no usefull info in the popup window. And also when I first do a manual find and replace, the popup window gives me nothing I can use.

(I also have a problem with the other script that the Create query doesn't do anything, but that easily solved by opening the find/replace window myself).

Votes

Translate

Translate

Report

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 Beginner ,
Aug 11, 2009 Aug 11, 2009

Copy link to clipboard

Copied

I've just tried it all again for the first time in ages

set up the Find Change search as normal then run the script

It puts the popup behind the main ID window, try minimising/hiding the main ID window

It's a popup window about three inches square called 'findchangestrings.txt'

Votes

Translate

Translate

Report

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
Contributor ,
Aug 11, 2009 Aug 11, 2009

Copy link to clipboard

Copied

Great, thanks, that works. I also found out you have to close that little txt window otherwise the next query won't show up. Nice!

Just one more thing (if you don't mind...): should I ignore this part: changeConditionsMode:1919250519? It shows uo in the changeTo section:

grep {findWhat:" ‘s "} {changeTo:" ’s ", changeConditionsMode:1919250519} {includeLockedStoriesForFind:false, includeLockedLayersForFind:false, includeHiddenLayers:false, includeMasterPages:false, includeFootnotes:true} //Comment

Votes

Translate

Translate

Report

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