Why won't this script work?

Well so yesterday I posted a question I had with join InDesign files, I thought that I had found a solution and I was wrong. Nothing is as humbling as script... anyway the gist of what I'm trying to do is trying to combine a lot of InDesign files in a single large document. The problem I encounter is that InDesign crashes. What is strange to me is that a single iteration of this script works oddly, however when I try to do with multiple InDesign files * the bed.

Any help on the figure, it would be much appreciated.

System: WIndows 7

Indy Version: CS5

(1) selecting a folder.

(2) get the files.

(3) open one at a time, and duplicate pages in another document. (Which I call OCD because I basically that is what I want to do with the giant document.)

(4) close the source file without saving the changes. Pages should not change, but better safe than sorry.

(5) close the (TOC) destination file and save it with the new pages to this subject.

inDesign #target

File = Folder.selectDialog ();

files = folder.getFiles ("*.") INDD");

for (var i = 0; i < files.length; i ++) {}

source_doc = app.open (files [i]);

destination_doc = app.open (file ("c: / / users//user//desktop//TOC.indd"))

REST();

}

function rest() {}

sourcePages = source_doc.pages.itemByRange (0, -1);

sourcePages.duplicate (LocationOptions.AFTER, destination_doc.pages.item(-1));

source_doc. Close (SaveOptions.no);

destination_doc. Close (SaveOptions.YES, "c://users//user//desktop//TOC.indd");

}

Couple of thoughts: the code is kind of a mess. I don't understand why you are opening and closing of your doc of destination with each iteration, or why you have stuff separated in another function, or why you have not any vars. As a general rule, I try to work on spreads rather than pages where possible. I avoid also itemByRange() because of the strange plural object that it returns. Here's one (in my opinion, in any case) cleaned script:

var folder = Folder.selectDialog(),
    files = folder.getFiles("*.INDD"),
    destination_doc = app.open(new File("c://users//user//desktop//TOC.indd")),
    source_doc, i, j;

for (i = 0; i < files.length; i++) {
    source_doc = app.open(files[i]);
    for (j = 0; j < source_doc.spreads.length; j++) {
        source_doc.spreads[j].duplicate(LocationOptions.AT_END, destination_doc);
    }
    source_doc.close(SaveOptions.NO);
}

destination_doc.close(SaveOptions.YES);

See if you have better luck with it.

Jeff

Tags: InDesign

Similar Questions

  • Why the habit of this script work?

    Hello

    I've used this script to make a portrait scroll bar that works perfectly, however I modified the script to work in a landscape scroll bar by altering the x and the y axis and switching on the height to the width. However a portion of it will not work... The left and right arrows are working properly but the bar scroll do not move and I for the life of me understand why.

    Does anyone have any ideas as to what ive missed or done wrong?

    Thanks in advance

    scrolling = function () {}

    var scrollWidth:Number = scrollTrack._width;

    var contentWidth:Number = contentMain._width;

    var scrollFaceWidth:Number = scrollFace._width;

    var maskWidth:Number = maskedView._width;

    var initPosition:Number = scrollFace._x = scrollTrack._x;

    var initContentPos:Number = contentMain._x;

    var finalContentPos:Number = maskWidth-contentWidth + initContentPos;

    var left: Number = scrollTrack._y;

    var top: Number = scrollTrack._x;

    var right: Number = scrollTrack._y;

    lower var: Number = scrollTrack._width - scrollFaceWidth + scrollTrack._x;

    var dy:Number = 0;

    var speed: Number = 10;

    var moveVal:Number = (contentWidth-maskWidth) /(scrollWidth-scrollFaceWidth);

    scrollFace.onPress = function() {}

    var currPos:Number = this ._x;

    startDrag (this, false, left, top, right, bottom);

    this.onMouseMove = function() {}

    DY = Math.abs(initPosition-this._x);

    contentMain._x = Math.round(dy*-1*moveVal+initContentPos);

    };

    };

    scrollFace.onMouseUp = function() {}

    stopDrag();

    delete this.onMouseMove;

    };

    btnUp.onPress = function() {}

    this.onEnterFrame = function() {}

    If (contentMain._x + speed < maskedView._x) {}

    If (scrollFace._x < = high) {}

    scrollFace._x = top;

    } else {}

    scrollFace._x = speed/moveVal;

    }

    contentMain._x += speed;

    } else {}

    scrollFace._x = top;

    contentMain._x = maskedView._x;

    delete this.onEnterFrame;

    }

    };

    };

    btnUp.onDragOut = function() {}

    delete this.onEnterFrame;

    };

    btnUp.onRelease = function() {}

    delete this.onEnterFrame;

    };

    btnDown.onPress = function() {}

    this.onEnterFrame = function() {}

    If (contentMain._x - speed > finalContentPos) {}

    If (scrollFace._x > = bottom) {}

    scrollFace._x = low;

    } else {}

    moveVal/scrollFace._x += speed;

    }

    contentMain._x = speed;

    } else {}

    scrollFace._x = low;

    contentMain._x = finalContentPos;

    delete this.onEnterFrame;

    }

    };

    };

    btnDown.onRelease = function() {}

    delete this.onEnterFrame;

    };

    btnDown.onDragOut = function() {}

    delete this.onEnterFrame;

    };

    If (contentWidth < maskWidth) {}

    scrollFace._visible = false;

    btnUp.enabled = false;

    btnDown.enabled = false;

    } else {}

    scrollFace._visible = true;

    btnUp.enabled = true;

    btnDown.enabled = true;

    }

    };

    scrolling();

    Even with this reduction, it is at best a tangle of code to try to reason with him.  I think I see you have nested functions at least two levels deep, possibly further because I do not see where the original ends, and the nesting of functions is prevented best, and most often unnecessary...

    scrolling = function () {}

       scrollFace.onPress = function() {}

    this.onMouseMove = function() {}

    }

    };

    };

    Since you're telling the problem is that the scroll bar does not move, it does not move in relation to press the keys or does not move relative to slide.

  • This script works under the cs5? display and if adapt to screen imported from cs3

    Hello

    I used to run this script every time that I open a photo in photoshop cs3 on xp

    now I use cs5 and windows 7

    I use this script to load the photo under the eyes and fit the image of the screen

    Image on screen adjustment

    Attach to the event Open Document in Photoshop CS 2

    // =======================================================

    var id57 = charIDToTypeID ("TPCV");

    var desc15 = new ActionDescriptor();

    var id58 = charIDToTypeID ("null");

    ref6 var = new ActionReference();

    var id59 = charIDToTypeID ("min");

    var id60 = charIDToTypeID ("MnIt");

    var id61 = charIDToTypeID ("FtOn");

    Ref6.putEnumerated (id59, id60, id61);

    desc15.putReference (id58, ref6);

    executeAction (id57, desc15, DialogModes.NO);

    //=======================================================

    id20 var = charIDToTypeID ("TPCV");

    var desc7 = new ActionDescriptor();

    id21 var = charIDToTypeID ("null");

    Ref3 var = new ActionReference();

    id22 var = charIDToTypeID ("min");

    var id23 = charIDToTypeID ("MnIt");

    var id24 = stringIDToTypeID ("screenModeFullScreenWithMenubar");

    Ref3.putEnumerated (id22, id23, id24);

    desc7.putReference (id21, ref3);

    executeAction (id20, desc7, DialogModes.NO);

    but I did notice the photo in photoshop is not very strong , I have the zoom with the mouse wheel it to be sharper

    What's wrong?

    the script is not compatible with cs5?

    is there something wrong in my setup?

    Thank you

    see you soon

    either by the way, I use another script to start photoshop

    selectTool ('handTool');

    selectTool ('handTool');

    function selectTool (tool) {}

    var desc9 = new ActionDescriptor();

    ref7 var = new ActionReference();

    Ref7.putClass (app.stringIDToTypeID (tool));

    desc9.putReference (app.charIDToTypeID ('null'), ref7);

    executeAction (app.charIDToTypeID ('slct'), desc9, DialogModes.NO);

    };

    Good Yes it works a bit strange in cs5.

    It seems to work better if the mode full screen with the menu bar is run first, then to adapt to the screen.

    Like this:

    Image on screen adjustment

    Attach to the event Open Document in Photoshop CS 2

    //=======================================================

    id20 var = charIDToTypeID ("TPCV");

    var desc7 = new ActionDescriptor();

    id21 var = charIDToTypeID ("null");

    Ref3 var = new ActionReference();

    id22 var = charIDToTypeID ("min");

    var id23 = charIDToTypeID ("MnIt");

    var id24 = stringIDToTypeID ("screenModeFullScreenWithMenubar");

    Ref3.putEnumerated (id22, id23, id24);

    desc7.putReference (id21, ref3);

    executeAction (id20, desc7, DialogModes.NO);

    // =======================================================

    var id57 = charIDToTypeID ("TPCV");

    var desc15 = new ActionDescriptor();

    var id58 = charIDToTypeID ("null");

    ref6 var = new ActionReference();

    var id59 = charIDToTypeID ("min");

    var id60 = charIDToTypeID ("MnIt");

    var id61 = charIDToTypeID ("FtOn");

    Ref6.putEnumerated (id59, id60, id61);

    desc15.putReference (id58, ref6);

    executeAction (id57, desc15, DialogModes.NO);

  • Why won't this work?

    I started a Microsoft account for my Windows laptop, 8. Then, I changed the primary alias to a different email address. I tried to add my previous as an alias account so that I could do the primary alias. Did not work. He said that it was already used. How can I get this back to the original address?

    Thank you

    KelseyE

    There is at least a day 30 Security hold until you can do it.  After that, you should be able to.

  • I have a MacBook Pro 2013 and installed from a disc of Lightroom 3.  I enter my serial number and it tells me it's wrong.  Why won't this work?

    I bought the product, have a serial number, and when I go to install from a superdrive drive, he told me that my serial number is not valid.  I have a MacBook Pro 2013 and it running Yosemite 10.10.5

    Thank you much for the help!

    Jericho

    Please see the links below.

    Hope this will help you.

    Kind regards

    Hervé Khare

  • Why did the Java script works on my work for Internet explore, but not for Firefox RSS feeds?

    I finished building the Web site for my girlfriend, and the rest is the RSS feed. It works just fine in IE 8, but Fire Fox 9 when the widget is clicked a bookmark box appears and asks if I want to save it as a bookmark. I'm not a programmer of the Java script so I hope help here! Here's the script:

  • "< a href ="http://www.susangabrielle.com/1/feed"title ="RSS"alt ="rss">< /a >"
  • The view is http://www.susangabrielle.com

    Probably you fixed, the RSS seems to work for me

  • Why won't this processor?

    I thought it would be good to replace my current processor 2.0 ghz... so I bought an AMD Phenom II x 4 965 processor Quad core (Black edition).

    So makes it a plug as indicated on the site to upgrade hp for my model of pc and made sure it was socket3...

    Then during the installation of this new processor, a message came on the screen saying it is NOT supported, and my PC is going to be shit down.

    Any help regarding, why is that happen and a difficulty as possible?

    I thought about it... it comes to 125w processor... my system can only top to 95w * facepalms *.

    Now to try to get an Exchange... lol

  • Why the Java plugin script works does not in PS?

    Have the demo version of PS CC 2015 d/load.

    When I try all the actions (for example to go to the bridge), I get say msg of error not complete command as long as PS could not found plugin java script.

    Am on Windows 7 64 bit

    Usage menu help > System Info... Look in the required section of the plug-in. Don't you see that listed ScriptingSupport in there?  If you do not have your Photoshop install did not work correctly.or you have some third party addon that requires him not not to load.  Try holding SHIFT as you start Photoshop and skip loading third-party addons...

  • Why won't save my work plans in a PDF file?

    When I try to save as a PDF file, two columns of the artboard to save.

    I downloaded my illustrator files in this link.

    Help, please!

    http://www.box.com/s/7e7f174426d346180974

    The file does not contain the work plan you need. What you need, it's a work plan for each inside and outside that surrounds the other 3 work plans.

  • Why doesn't this hitTestPoint work?

    Probably I'm missing something on which settings I'm supposed to be in the way.

    Here is the code:

    In the first class (the object hit belongs to this class):

    gp.lockPiece (e.stageX, e.stageY);

    In the second class (referred to above as gp, the object to be affected belongs to this class):

    public void lockPiece (gx, gy) {}
    If (this.hitTestPoint (gx, gy, true)) {}
    this.isLocked = true;
    this.gotoAndStop ("Lock");
    trace (this.isLocked);
    }
    else {}

    trace ("failed.");
    }
    }

    It traces always "did not work" when I drag the instance of the class from the instance of the second class first. As I understand it not on the function hitTestPoint?

    What is highlighted could be added to a table and every time you check your hittest, check if each element of the array is hit.  If this is not the case, turn off highlight it.

  • Why won't my loop work?

    I'm a tutorial to learn actionscript 3.0 and I'm having a small problem. I create a game of blackjack. I'm to the point where I hit the button to stay and the dealer reveals his cards. I've set up a loop for to take care of this. The problem is, for some reason, the loop only runs once. It must run at least twice. I've done a trace statement to ensure that it was said to run it twice and it was. Why is he only performed a first time? I also get a message that says:

    "TypeError: Error #1010: a term is undefined and has no properties."
    at blackjack_fla::MainTimeline/checkWin()
    to blackjack_fla::MainTimeline/stay().

    I think that this error is related to the problem with the loop the loop is part of the checkWin() function.

    Here's what the code of the loop looks like:

    for (var i: uint = 0; i < dealerCards.length; i ++)
    {
    tempCard = MovieClip (dealerContainer.getChildAt (i));
    tempCard.gotoAndStop (dealerCards [i] .cardType);
    tempCard.values_mc.gotoAndStop (dealerCards [i] .cardName);
    }

    Thanks for taking a peek at my code.

    It is not loop twice because the code stops executing when it hits the error, which is

    tempCard.values_mc.gotoAndStop (dealerCards [i] .cardName);

    so, the problem is that flash does not like that you say stop to the ACE, or that there is something wrong with values_mc.

  • My script works with a #1009 error?

    Hi all

    I spent so much time trying to understand and I do not understand, I have this script where the error #1009 is displayed continually, the stange thing: my script works correctly and I want to get quotes off the coast of this error. When my script is 'correct', which means, no more errors appear, the script does not work with the external swf. The target of the red error 'movie01' in the script, but this reference was already used successfully, why not this one?

    This script works but with the error #1009:

    var movie02:Loader = new Loader();

    movie02. Load (new URLRequest("test/seq.swf"));

    addChild (movie02);

    movie01.addEventListener (Event.ENTER_FRAME, seq01);

    function seq01(main:Event):void {}

    var movie01:MovieClip = main.target.content;

    If {(this.currentFrame is 15)

    movie01. Play();

    }

    If (movie01.currentFrame == 150) {}

    This.Stop ();

    }

    }

    Thank you

    Alain

    :

    var movie01:Loader = new Loader();
    movie01.contentLoaderInfo.addEventListener (Event.Complete, LoadComplete);
    movie01. Load (new URLRequest("test/seq.swf"));
    addChild (movie01);

    movie01.contentLoaderInfo.addEventListener (Event.Complete, LoadComplete);
    function loadcomplete(e:Event) {}
    movie01.addEventListener (Event.ENTER_FRAME, seq01);
    }

    var exectedPreviously:Boolean

    function seq01(main:Event):void {}
    var mc:MovieClip = MovieClip (main.target.content);
    If (this.currentFrame == 15 &! executedPreviously) {}

    executedPreviously = true;
    MC. Play();
    }
    If {(mc.currentFrame is 150)
    This.Stop ();
    }
    }

  • I am a student and have this version of CC. I've updated my card number and still, it won't let me open or use one of my applications such as photoshop or illustrator. Could someone help me please? I need this to work!

    I am a student and have this version of CC. I've updated my card number and still, it won't let me open or use one of my applications such as photoshop or illustrator. Could someone help me please? I need this to work!

    check your account to ensure that your payment has been processed using your adobe id, https://helpx.adobe.com/x-productkb/policy-pricing/remove-credit-card-info-adobe-account.h tml

    If she is, log out and then back to your desktop app cc using this same id adobe, connect and disconnect activate Cloud Creative applications

  • I don't know why I get the error "function object is not defined" with this script.

    Hello

    I have a script which adds a unique model in the render queue and applying a Render parameter model and model output for adding module make element of queue.  For some reason, I am getting an error on the first line which reads:

    app.project.renderQueue.items (1), .applyTemplate ('MY SETTINGS');

    I have attached the image of here error dialog:

    Screen shot 2011-07-28 at 12.28.32 PM.png

    Here is a part of the script.

            var currentProjectItem;
            var globalCompItemID;
            var renderCompItemID;
    
            for (var i=1;  i <= app.project.numItems; i++)
            {
                currentProjectItem = app.project.item(i);
                if (currentProjectItem.name == "globals")
                {
                    globalCompItemID = i;
                } else if (currentProjectItem.name == "!_FINAL RENDER") {
                    renderCompItemID = i;
                }
            }
    
            //add the necessary preview render jobs
            app.project.renderQueue.items.add(app.project.item(renderCompItemID));
            app.project.renderQueue.items(1).applyTemplate("MY SETTINGS");               <---THIS IS WHERE AE ERRORS
            app.project.renderQueue.items(1).outputModules[1].applyTemplate("MY SETTINGS");
            app.project.renderQueue.items.add(app.project.item(renderCompItemID));
            app.project.renderQueue.items(2).applyTemplate("MY SETTINGS");
            app.project.renderQueue.items(2).outputModules[1].applyTemplate("MY SETTINGS");
            app.project.renderQueue.items.add(app.project.item(renderCompItemID));
            app.project.renderQueue.items(3).applyTemplate("MY SETTINGS");
            app.project.renderQueue.items(3).outputModules[1].applyTemplate("MY SETTINGS");
    
     
    

    The model I want to add is added to the render queue, it simply refuses to invoke the method applyTemplate() on the most recently added make queue item.

    Any ideas why I get this error?

    Thank you!

    I think that from the line where the error occurred, you must use renderQueue.item () instead of renderQueue.items () (except when you add something to the rendering queue).

    Dan

  • Why I constantly get a message that says... "Stop running this script?"

    I constantly get a pop of message asking me if I want to "stop running this script"... a script on this page slows down Internet Explorer runs slowly. It happens on Facebook, no matter what I do, be it games or on the FB homepage.

    Follow this article http://support.microsoft.com/kb/175500

    Kind regards

Maybe you are looking for