How can I make a long list find-change only on Master

Hi everyone
I got this script:
var myDocuments = app.documents.everyItem();
var myLayers = myDocuments.layers.everyItem();
//Locked text frames on master spreads are not touched.
//If you want to unlock them you have to add something like this:
//Unlock ALL page items in every document on spreads and master spreads (optional):
myDocuments.pageItems.everyItem().locked = false;
var myPageItemsOnNormalSpreads = myDocuments.spreads.everyItem().pageItems.everyItem();
//Unlock the layers (optional)
myLayers.locked = false;
//Lock all first level page items on normal spreads
//That leaves the page items on master spreads unlocked:
myPageItemsOnNormalSpreads.locked = true;
//Now for the GREP part:
app.findChangeGrepOptions.includeMasterPages = true;
app.findGrepPreferences = changeGrepPreferences = null;
app.findGrepPreferences.findWhat = "\\b20\\d+\\b";
//Do the search on "all open document" level
//That will return an array of arrays:
var myTarget = myDocuments.findGrep();
//Flattening the myTarget array:
var flattenedFoundArray = [];
for(var n=0;n<myTarget.length;n++){
    flattenedFoundArray = flattenedFoundArray.concat(myTarget[n]);
//Change contents of found texts in flattened array:
for(var n=flattenedFoundArray.length-1;n>=0;n--){
    flattenedFoundArray[n].contents = String(Number(flattenedFoundArray[n].contents) + 1);
//Unlock all objects on normal spreads:
myPageItemsOnNormalSpreads.locked = false;
//Reset GREP find and change prefs:
app.findGrepPreferences = changeGrepPreferences = null;
made by Uwe
I change it into this, aim to make a mulit items of find-change only on master
//==============================================================================
var myDocuments = app.documents.everyItem();
var myLayers = myDocuments.layers.everyItem();
//Locked text frames on master spreads are not touched.
//If you want to unlock them you have to add something like this:
//Unlock ALL page items in every document on spreads and master spreads (optional):
myDocuments.pageItems.everyItem().locked = false;
var myPageItemsOnNormalSpreads = myDocuments.spreads.everyItem().pageItems.everyItem();
//Unlock the layers (optional)
myLayers.locked = false;
//Lock all first level page items on normal spreads
//That leaves the page items on master spreads unlocked:
myPageItemsOnNormalSpreads.locked = true;
//Now for the GREP part:
app.findChangeGrepOptions.includeMasterPages = true;
app.findGrepPreferences = changeGrepPreferences = null;
app.findGrepPreferences.findWhat = "USA";
//Do the search on "all open document" level
//That will return an array of arrays:
var myTarget = myDocuments.findGrep();
//Flattening the myTarget array:
var flattenedFoundArray = [];
for(var n=0;n<myTarget.length;n++){
    flattenedFoundArray = flattenedFoundArray.concat(myTarget[n]);
//Change contents of found texts in flattened array:
for(var n=flattenedFoundArray.length-1;n>=0;n--){
    flattenedFoundArray[n].contents = "CHINA";
//Unlock all objects on normal spreads:
myPageItemsOnNormalSpreads.locked = false;
//Reset GREP find and change prefs:
app.findGrepPreferences = changeGrepPreferences = null;
var myDocuments = app.documents.everyItem();
var myLayers = myDocuments.layers.everyItem();
//Locked text frames on master spreads are not touched.
//If you want to unlock them you have to add something like this:
//Unlock ALL page items in every document on spreads and master spreads (optional):
myDocuments.pageItems.everyItem().locked = false;
var myPageItemsOnNormalSpreads = myDocuments.spreads.everyItem().pageItems.everyItem();
//Unlock the layers (optional)
myLayers.locked = false;
//Lock all first level page items on normal spreads
//That leaves the page items on master spreads unlocked:
myPageItemsOnNormalSpreads.locked = true;
//Now for the GREP part:
app.findChangeGrepOptions.includeMasterPages = true;
app.findGrepPreferences = changeGrepPreferences = null;
app.findGrepPreferences.findWhat = "Washington DC";
//Do the search on "all open document" level
//That will return an array of arrays:
var myTarget = myDocuments.findGrep();
//Flattening the myTarget array:
var flattenedFoundArray = [];
for(var n=0;n<myTarget.length;n++){
    flattenedFoundArray = flattenedFoundArray.concat(myTarget[n]);
//Change contents of found texts in flattened array:
for(var n=flattenedFoundArray.length-1;n>=0;n--){
    flattenedFoundArray[n].contents = "Beijing";
//Unlock all objects on normal spreads:
myPageItemsOnNormalSpreads.locked = false;
//Reset GREP find and change prefs:
app.findGrepPreferences = changeGrepPreferences = null;
//===============================================================================
only what I can do is repeat and repeat again
is that another perfect solution to do that?
thanks
Teetan

Try this,
findChange("USA", "CHINA");
findChange("Washington DC", "Beijing");
function findChange (findWhat, changeContent){
    var myDocuments = app.documents.everyItem();
    var myLayers = myDocuments.layers.everyItem();
    //Locked text frames on master spreads are not touched.
    //If you want to unlock them you have to add something like this:
    //Unlock ALL page items in every document on spreads and master spreads (optional):
    myDocuments.pageItems.everyItem().locked = false;
    var myPageItemsOnNormalSpreads = myDocuments.spreads.everyItem().pageItems.everyItem();
    //Unlock the layers (optional)
    myLayers.locked = false;
    //Lock all first level page items on normal spreads
    //That leaves the page items on master spreads unlocked:
    myPageItemsOnNormalSpreads.locked = true;
    //Now for the GREP part:
    app.findChangeGrepOptions.includeMasterPages = true;
    app.findGrepPreferences = changeGrepPreferences = null;
    if(findWhat)app.findGrepPreferences.findWhat = findWhat;
    //Do the search on "all open document" level
    //That will return an array of arrays:
    var myTarget = myDocuments.findGrep();
    //Flattening the myTarget array:
    var flattenedFoundArray = [];
    for(var n=0;n<myTarget.length;n++){
        flattenedFoundArray = flattenedFoundArray.concat(myTarget[n]);
    //Change contents of found texts in flattened array:
    for(var n=flattenedFoundArray.length-1;n>=0;n--){
        if(changeContent)flattenedFoundArray[n].contents = changeContent;
    //Unlock all objects on normal spreads:
    myPageItemsOnNormalSpreads.locked = false;
    //Reset GREP find and change prefs:
    app.findGrepPreferences = changeGrepPreferences = null;
Vandy

Similar Messages

  • When pressing Ctrl+f to find something in a page the Find box remains open until I close it, in ALL tabs I have in the firefox window. How can I make firefox open the Find box ONLY in the tab I am in?

    When pressing Ctrl+f to find something in a page the Find box remains open until I close it, in ALL tabs I have in the firefox window. How can I make firefox open the Find box ONLY in the tab I am in?

    Firefox 4 and later versions save the previous session automatically, so there is no longer need for the dialog asking if you want to save the current session.<br />
    Use "File > Exit" or "Firefox > Exit" (Mac: "Firefox > Quit Firefox") if you want to restore multiple windows.<br />
    You can use "History > Restore Previous Session" to get the previous session at any time.<br />
    You may need to click the orange/gray Firefox button to see History.<br />
    There is also a "Restore Previous Session" button on the default <b>about:home</b> Home page.
    Another possibility is to use:
    * [http://kb.mozillazine.org/Menu_differences Firefox/Tools > Options] > General > Startup: "When Firefox Starts": "Show my windows and tabs from last time"

  • How can I make a backup listing of all of my Firefox bookmarks, with complete URLs, so I can print it out from a word processing document?

    == Issue
    ==
    I have a problem with my bookmarks, cookies, history or settings
    == Description
    ==
    How can I make a backup listing of all of my Firefox bookmarks, with completely written out URLs, so I can print it out from a word processing document? Please email me the answer-
    [email protected]
    <blockquote>duplicate. Locked. Please continue [https://support.mozilla.com/en-US/forum/1/727213 here] -MJB</blockquote>
    == Firefox version
    ==
    2.0.0.4
    == Operating system
    ==
    PPC Mac OS X Mach-O
    == User Agent
    ==
    Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4
    == Plugins installed
    ==
    *-Netscape Navigator Default Plug-in
    *Runs Java applets using the latest installed versions of Java. For more information: Java Embedding Plugin. Run version test: Test Your JVM.
    *Plugin that plays RealMedia content
    *The QuickTime Plugin allows you to view a wide variety of multimedia content in web pages. For more information, visit the QuickTime Web site.
    *Shockwave Flash 9.0 r260
    *Provides support for Digital Rights Management
    *Provides support for Windows Media.
    *Java 1.3.1 Plug-in (CFM)
    *Macromedia Shockwave for Director Netscape plug-in, version 8.5.1
    *Java 1.3.1 Plug-in

    Hello.
    Although possibly not related to your problem, I have to remind you that the version of Firefox you are using at the moment has been discontinued and is no longer supported. On top of this, it has known unpatched bugs and security problems. I urge you to update to the latest version of Firefox, for maximum security, stability, performance and usability. You can get it for free, as always, at [http://www.getfirefox.com getfirefox.com].

  • How can I make ringtone longer before answer machine cuts in?

    How can I make ringtone longer before answer machine cuts in?

    Doesn't matter, carriers determine time before voicemail kicks in.

  • HT1364 I have moved my library to an external hard drive and changed the location of the iTunes media folder in Preferences, but every time I close and re-open iTunes, I have to do it all over again.  How can I make the iTunes media folder change permanen

    I have moved my library to an external hard drive and changed the location of the iTunes media folder in Preferences, but every time I close and re-open iTunes, I have to do it all over again.  How can I make the iTunes media folder change permanent?  I have an older machine with Windows XP.

    I don't believe mounting the hard drive should be necessary, unless you have several external drives and want your computer to recognise them as folders, rather than drives. I've never had to mount a hard drive, ever. If you don't know how to do it, then it shouldn't be necessary now.
    Try this:
    Prepare iTunes so that it can see the external drive.
    Make a note of which drive-letter the external drive has been allocated. (Look in Windows Exploer)
    Look at the file location for a song. Make sure it plays (and therefore that iTunes has found it). Highlight it and select File/Get Info/Summary>Where: and make a note of the drive letter for that song.
    Close and shut down the computer.
    The next time you turn the computer on again, connect the external drive
    Before you start iTunes - check the external drive in Windows Explorer. Is it ready, does it have the same drive-letter that it had last time? Can you go into the drive and see the files on it?
    Once you can, start iTunes. (If the drive lettter has changed, you need to work out why before going any further.)
    If iTunes fails to find your external drive, you need to check where iTunes is looking for your Library.
    Select the same song you checked before (presumably iTunes can no longer find it). Follow the procedure for locating it. You should be able to see where iTunes thinks the file is. It's the drive that counts. Which drive letter is iTunes looking at? Is it the same one that it was previously (which should also be the same one that the drive has now).
    What happens, which step do you have problems with?
    Message was edited by: the fiend

  • The address window has shrunk. How can I make it longer so I can see the address (or most of it at least)?

    I have updated to Firefox 3.6.23 for Mac. I have OS 10.4.11. Immediately I noticed that the address window has been reduced to about half an inch. The search window is long, like the address window used to be. This is not good for me. I usually use the address window to make changes and move to a new page. I cannot do this now. How can I make the address window long again? Can I go back to 3.6.22? I need that long window.
    Sincerely,
    Gerald E. Strickland
    Bradenton, Florida

    You can place the mouse between the location bar and the search bar and it will become a resize icon.<br />
    Press the left mouse button and drag it to the right to make the location bar wider.
    You can also reset the relative wides by deleting localstore.rdf in the Firefox Profile Folder
    *http://kb.mozillazine.org/Profile_folder_-_Firefox
    *http://kb.mozillazine.org/localstore.rdf

  • How can I make sure linked in contacts are only added once?

    For some reason the linkedin contacts are appearing endlessly in my mac address book. Every time I delete they come back - Very annoying especially since I have to delete folders manually one by one. How can I make sure linked in contacts only added once? And how can I delete from mac address book  in one go?

    If you installed software from LinkedIn to synchronize the contacts, refer to the developer for support. Otherwise, how did you import the contacts?

  • How can I make an email list from my submissions?

    How can I compile a list of submitted emails to send out a group mailing?

    Highlight it in Mail > Preferences > Account and click on the "-" tab at the bottom of the list panel.

  • How do I make a script to find/change many in one go

    I have a long list of words that I do a find/change to avoid breaks and keep with the next word. Words like Dr. Mr. Mrs. :
    Is there an easy way to put all the words and symbols that I want to change into one script to save doing each one at a time?

    1) Free solution: FindChangeByList.jsx
    (in \Scripts\Scripts Panel\Samples\JavaScript)
    2) Better and very flexible solution: Multi-Find/Change
    http://www.automatication.com/index.php?id=12
    @+
    Marc

  • How can I make the Sharepoint List Alert email format more readable?

    Hi,
    Been wrestling with the issue for a while now. I have a list on my company's Sharepoint site online. I have configured this list to send alerts every morning for all the new list entries that have come in the previous day. Unfortunately, the emails are very
    hard to read as they don't do a good job at all of distinguishing columns. There is no border or gradient separation between the data in one column vs. another in the email. This might have been OK, but the column headers appear in the middle of the text box
    for the column. I previously used an on-premises version of sharepoint and this wasn't an issue, the alerts would come out very clean. 
    Is the alert format a function of the theme we chose (basic theme, no gradient, etc.)? I can look into changing my company's theme if that is the case. If not, is there a way to change the format of a specific alert?
    Thank you for your help.

    I am afraid there is no way to change the alert format in SharePoint Online. The AlertTemplates.xml file is present in physical hive folder of SharePoint in Template\XML directory. And in SharePoint Online, you are not allowed to changes the physical file.
    Secondly, all of the styles related to alert are present in this file, so changing the theme on the site won't have any effect. In fact I did test it with several different themes just to make sure there isn't any change in run time and every time the format
    remained same.
    Thanks,
    Nadeem
    Please remember to up-vote or mark the reply as answer if you find it helpful.

  • How can I make a random list from list of names?

    I have a list of names and i need to place them randomly in a new list. How I make this in the Numbers?
    Tk's
    Rafael

    Here's one way:
    There are two formulas in the Sorter table.
    B2 (and filled down):   =RAND()
    A2 (and filled down):   =OFFSET(Data :: $A$1,RANK(B2,B,),0)
    The first generates a set of random values between 0 and 1 in column B.
    The second calculates the rank within the list of the column B value in its row, and uses that rank to determine how many rows below row 1 to look for the value to place in its cell.
    The checkbox cell in Go! offers a simple way to change a value, which triggers a recalculation of the Sorter table.
    Regards,
    Barry

  • HT4392 My macbook air goes to sleep mode after 2 minutes, how can I make this longer? It's frustrating trying to work.

    Hello,
    I am struggling to get my macbook air on a longer sleep mode, i have searched through the settings and trying putting the saver onto a longer time, however this does nothing. Now my macbook keeps going to skeep after two minutes and its really quite frustrating, can anyone help me?

    Go to Apple menu / System Preferences / Energy Saver.
    Change the settings for computer sleep and display sleep to what you want them to be.
    Next - important step - reset the PRAM.
    Shut down your Mac.
    Locate the following keys on the keyboard: Command (⌘), Option, P, and R. You will need to hold these keys down simultaneously in step 4.
    Turn on the computer.
    Press and hold the Command-Option-P-R keys before the gray screen appears.
    Hold the keys down until the computer restarts and you hear the startup sound for the second time.
    Release the keys.

  • How can I make a PDF listing by artist as before?

    Now I only get an album listing alphabetically instead an artist list and all your albums.

    This only listing by album.
    --album a from artist A
    --album a from artist B
    --album a from artist C
    --album b from artist A
    --album b from artist B
    --album b from artist C
    --album c from artist A
    --album c from artist B
    --album c from artist C
    Want I need - listed by artists:
    --album a from artist A
    --album b from artist A
    --album c from artist A
    --album a from artist B
    --album b from artist B
    --album c from artist B
    --album a from artist C
    --album b from artist C
    --album c from artist C
    The focus is the artist and then the albums+artworks.
    I always did this. Like song listing + artwork.
    Did 8.1.1 remove this feature?
    Message was edited by: Verzig

  • How can I make this in labview : find the numbers of overlapping between bits

    Dear
    I have this problem it really so complex to solve for me
    its not home work its related to my academic research
    I have two stream of bits each one with fixed n bits length as follow:
    x=1,1,1,1,0,0,0,0
    y=1,1,1,0,0,0,0,0
    I need to extract the following information
    a1, the number of overlapping 1s:in this case is 3
    a2, the number of overlapping 1s of X and 0s of Y :in this case is 1
    a3, the number of overlapping 0s of X and 1s of Y:in this case is 0
    a4, the number of overlapping 0s on both x,y.:in this case is 4
    thank in advance
    best regards
    hi ?Q>
    Solved!
    Go to Solution.

    alexderjuengere wrote:
    just for fun, here's a numeric approach. the u8 arrays are limited to 0 and 1.
    Alex, I think the idea was a binary representation, not a decimal array of 1's or zeros:
    CLA, LabVIEW Versions 2010-2013
    Attachments:
    checkbits.png ‏8 KB

  • How can I make the standby button also change ringer profile?

    I do not use a holster but would like the standby mode (pressing mute) to use the holster profile settings.  Or if this is not possible is there any way to make it automatically change ringer profiles when placed in standby?  I would like to change to vibrate when in standby mode as the phone will be in my pocket.

    Standby option is capable of doing so. That wish can be materialized only if you use holster.
    tanzim                                                                                  
    If your query is resolved then please click on “Accept as Solution”
    Click on the LIKE on the bottom right if the post deserves credit

Maybe you are looking for