Batch combine files into one illustrator document - how to open target document?

I am making a script which will:
1) Open a folder of Illustrator files
2) Open each file in the folder (these files are called the source files)
3) Select all the contents of the source file
4) Copy the contents of the source file
5) Paste these contents into a target file as a new layer
6) Ensure the new layer has the same name as the old source file
However, I don't know how to tell Illustrator where my target file is. How can I do this?
Also, when I paste, how can I turn off paste rembers layers. (So the layers get pasted into the new layer that has the same name as the old document).
Here is my code:
// JavaScript Document
//Set up vairaibles
var destDoc, sourceDoc, sourceFolder;
// Select the source folder.
sourceFolder = Folder.selectDialog('Select the folder with Illustrator files that you want to mere into one', '~');
// If a valid folder is selected
if (sourceFolder != null) {
          files = new Array();
          // Get all files matching the pattern
          files = sourceFolder.getFiles();
          if (files.length > 0) {
                    // Get the destination to save the files
                    destDoc = document.selectDialog('Select the final saved document', '~');
                    for (i = 0; i < files.length; i++) {
                              sourceDoc = app.open(files[i]); // returns the document object
                              var myLayers = sourceDoc.layers; // All layers in Active Document
                              //Go through all layers of source document and copy artwork
                              for (i = 0; i < myLayers.length; i++) {
                                        myLayers[i].hasSelectedArtwork = true;
                              with(sourceDoc) {
                                        var count = pageItems.length;
                                        for (var i = 0; i < count; i++) {
                                                  pageItems[i].selected = true;
                                        redraw();
                                        copy();
                                        for (var i = 0; i < count; i++) {
                                                  pageItems[i].selected = false;
                              //Create a new title variable that has the title of the source document
                              var title = sourceDoc.name;
                              var title = title.substring(0, title.length - 4); //(remove extension from name)
                              //Close the Source Document
                              sourceDoc.close(SaveOptions.DONOTSAVECHANGES);
                              //Open the Destination Document and create a new layer in it that is named after the title variation
                              var newLayer = destDoc.layers.add();
                              newLayer.name = title;
                              //Paste into this new layer
                              destDoc = app.paste();
          else {
                    alert('No matching files found');
Thanks in advance for any help   
Edit: Also, when pasting, how can I paste in place instead of just pasting.

I have been studying this script. It is similar to what I need except it places the source files (Instead of copying & pasting them)
http://kelsocartography.com/blog/?p=204
I have adapted the script to my needs and it works perfectly, except it has the same problem as before: It pastes the first source file, but then it endlessly starts pasting the second source file (in a loop) and so I have to force quit.
So my new question is, when looping through files how can you get illustrator to move on the next one?
The original kelsocartography had this line:
thisPlacedItem = newLayer.placedItems.add()
thisPlacedItem.file = imageList[i];
I belive this line is what makes Illustrator move onto the next file, but I am not sure how to adapt it to my code.
Here is my code so far:
function getFolder() {
          return Folder.selectDialog('Please select the folder to be imported:', Folder('~'));
function importFolderAsLayers(selectedFolder) {
          // if a folder was selected continue with action, otherwise quit
          var myDocument;
          if (selectedFolder) {
                    myDocument = app.documents.add();
                    var firstImageLayer = true;
                    var newLayer;
                    var thisPlacedItem;
                    // create document list from files in selected folder
                    var documentList = selectedFolder.getFiles();
                    for (var i = 0; i < documentList.length; i++) {
                              // open each document in file list
                              if (documentList[i] instanceof File) {
                                        // get the file name
                                        var fName = documentList[i].name.toLowerCase();
                                        var sourceDoc = app.open(documentList[i]); // returns the document object
                                        var myLayers = sourceDoc.layers; // Select All layers in Active Document
                                        //Go through all layers of source document and copy artwork
                                        for (i = 0; i < myLayers.length; i++) {
                                                  myLayers[i].hasSelectedArtwork = true;
                                        with(sourceDoc) {
                                                  var count = pageItems.length;
                                                  for (var i = 0; i < count; i++) {
                                                            pageItems[i].selected = true;
                                                  redraw();
                                                  copy();
                                                  for (var i = 0; i < count; i++) {
                                                            pageItems[i].selected = false;
                                        //Create a new title variable that has the title of the source document
                                        var title = sourceDoc.name;
                                        var title = title.substring(0, title.length - 4); //(remove extension from name)
                                        //Close the Source Document
                                        // check for supported file formats
                                        if ((fName.indexOf(".eps") == -1)) {
                                                  continue;
                                        } else {
                                                  if (firstImageLayer) {
                                                            newLayer = myDocument.layers[0];
                                                            firstImageLayer = false;
                                                  } else {
                                                            newLayer = myDocument.layers.add();
                                                  // Give the layer the name of the image file
                                                  newLayer.name = fName.substring(0, fName.indexOf("."));
                                                  // Place the image on the artboard
                                                  sourceDoc.close(SaveOptions.DONOTSAVECHANGES);
                                                  //Paste into this new layer
                                                  newLayer = app.paste();
                    if (firstImageLayer) {
                              // alert("The action has been cancelled.");
                              // display error message if no supported documents were found in the designated folder
                              alert("Sorry, but the designated folder does not contain any recognized image formats.\n\nPlease choose another folder.");
                              myDocument.close();
                              importFolderAsLayers(getFolder());
          } else {
                    // alert("The action has been cancelled.");
                    // display error message if no supported documents were found in the designated folder
                    alert("Rerun the script and choose a folder with images.");
                    //importFolderAsLayers(getFolder());
// Start the script off
importFolderAsLayers(getFolder());

Similar Messages

  • "In Adobe Standard, when combining files into one pdf, how do I keep the original date"?

    I converted multiple emails into a pdf file.  After opening the pdf file, I wanted to combine the files into one pdf however once combining the files, the date modified of the files changes to the current date.  How do I preserve the original dates of the emails when combining the files?

    Hi Softball ,
    Thank You for posting on the forums. Apparently there is no such feature that would help you to achieve this.
    Thanks,
    Vikrantt Singh

  • I NEED HELP ON COMBINING FILES INTO ONE PDF FILE

    HOW CAN I TAKE 6 FILES AND MAKE THEM INTO ONE PDF FILE?

    Hi GOLDENSOROR
    How to merge files into one PDF:
    Within Acrobat XI, select File > Create > Combine Files into a Single PDF.
    Click Add Files and select the files you want to add.
    Click, drag, and drop to reorder the files and pages. Double-click on a file to expand and rearrange individual pages. Press the Delete key to remove unwanted content.
    When finished arranging the files, click Combine Files.
    Select File > Save As > PDF.
    Name your PDF file and click Save.
    Please refer : http://www.adobe.com/products/acrobat/merge-pdf-files.html

  • Combine files into one folder and send

    How do I combine separate PDFs into one folder which I can attach to an email and send as folder?  What adobe services do I need?

    You cannot email folders, unless you compress the whole folder into a ZIP file.  However, the zipped folder structure may not be compatible with other operating systems.
    Better just place all PDF docs into one ZIP file and send it like that.
    I don't think Adobe has any tools that can help you with that; unless Adobe Send contains something similar.

  • Combine files into one MP3 file

    I hope I can explain this correctly, but I want to know if there is a way to combine chapters of a disc into one larger MP3 file. I am importing all of my audiobooks into iTunes so that I can listen to them on my iPhone. However, there are so many discs with chapters that I would like to condense them into fewer but larger files. I hope this would condense the overall memory usage and make it easier to navigate.
    Is there a program on the Mac or for the Mac that can do something like this? I am on an iMac with Snow Leopard.
    THANKS!!!!

    See this -> Join Together
    "Join Together automates the process of joining the files of selected iTunes tracks together with QuickTime and exporting them as a single AAC Music or Audiobook file/track. Optionally, you can then create a "chapterized" audio file of the exported AAC file with pointers to the individually joined tracks."
    I am on an iMac with Snow Leopard.
    You need to change your signature.

  • How to package other jar files into one jar?

    How to package other jar files into one jar? How can i get the class in the inner jar file?

    Generally not a good idea. The Java runtime won't be able to load classes from those "inner" jars, you'd have to write your own classloader to do that. It's not a brilliant idea, generally, anyway, since the point of having lots of jars is to keep your application modular. Bundling them all together like that means you have to re-deploy the whole thing to fix, for instance, one small bug in one small library
    If you really want to do this, there's an Eclipse plugin called FatJar, but I urge you to consider whether you really want to do it first.

  • I have multiple documents how can I combine them into one document?

    I have multiple document files in Pages. How can I combine them into one document?

    Menu > View > Page Thumbnails > click on the thumbnails > Copy/Paste into thumbnails of other document
    Peter

  • I have two different itunes music files on my computer.  How do I combine them into one file?

    I have two different itunes music files on my computer.  How do I combine them into one file?

    I don't think so. The only other ID I have is a developer id, and I didn't get that until several months after I got the phone. In addition purchases I made from the App Store onthe phone would sync up with It unes on the Mac meaning it would be the same id.
    However I looked at the AppStore on my phone while it was connected to the Mac with iTunes open, and now the balance has changed to the same as the others.

  • TS3981 After migration files are now shared between two user accounts. How can I combine them into one account?

    After migration, from PC, files are now shared between two user accounts.I have to switch users to access files. How can I combine them into one account?

    See Pondini's  Transferring files from one User Account to another, for starters

  • How do I combine several pdf files into one so I can send them as one file.

    how do I combine several pdf files into one so I can send them as one file

    Reader doesn't have that ability. You would need Acrobat.

  • How to import multiple XML files into one inDesign document without copy/paste ?

    I use InDesign CS6, and I have several XML files with the same structure. Only the data are different.
    I created  an Indesign layout with some tagged placeholder frames on merge mode, for automated layout.
    Today for each XML file I have to create a new InDesign document to import the XML. Everything works fine. Then in order to have all Indesign layouts one after the other into a single Indesign layout, I have to use the copy/paste function.
    I mean for example, copy the contents of all documents to the first one. Or add pages of other documents to the first one, then delete spaces between each page.
    So my question is the following:
    How to repeat this process without copy/paste function, knowing that the
    number of XML files could be unknown.
    Thank you very much for your answer.

    Yes, effectively I would like to catalogue the files into one collection so i can save as one PDF and Print as one.:)
    I know I could save each AI as a pdf them then merge the pdf's together in acrobat, but I have nearly 100 files so would feel more comfortable seeing them all together before print / saving.
    My concern is that if I insert them in Ai, will the file resolution reduce? and will the ai still be editable and would it update the indesign file?
    Thanks for the quick reply

  • How to combine multiple purchased aac files into one aac file

    I recently purchased in iTunes an album consisting of 16 m4a files.  I ended up creating a playlist in iTunes for the songs.  I would like to create one m4a file which combines all and then play it in iTunes.  Is the copy protection preventing me from doing so?
    I know how to convert m4a files that I have converted to mp3 and combine them using Terminal with a cat command.  Then I import that combined file into iTunes.  All is well in this case.  I tried this with the 16 m4a files and I could not import the resultant mp3 file into iTunes.
    Any way to combine multiple purchased aac files?

    A simple way to accomplish the job, though not recommended is to print the 2 page file to a new PDF with multi-up (assuming you select vertical rather than horizontal locations) and adjust the paper in the Adobe PDF printer to be 8.5X22. At least you might give it a shot. Some variation, along with rotation possibly, might work.

  • How to combine several files into one?

    How to combine several pdf files into one?

    Combine Files is a feature of Acrobat Pro.  Because Reader Touch does not support the feature (yet), this is not the right forum for the question.
    Here's the Acrobat forum for Creating, Editing & Exporting PDFs.
    http://forums.adobe.com/community/acrobat/creating__editing_%26_exporting_pdfs
    You can ask questions and get help from Acrobat experts there.  Good luck!

  • How to combine .wmv files into one file???

    Hello Apple World,
    Can someone tell me a software that will allow me to combine ".wmv" files into one? I have several files that I need to combine then add music to. VERY simple with several software packages frow Windows pc's, but I'm struggling with this since getting my first mac! PLEASE help.

    Hi:
    How can I edit MPEG or convert DVD or MPEG to DV
    http://www.sjoki.uta.fi/%7Eshmhav/SVCDon_a_Macintosh.html#edit_convertMPEG
    Matti says it better than any of us:
    how/where you can join clips with Streamclip
    Also MPEG Streamclip guide explains it.
    MPEG Streamclip can join similar MPEG files: The joined files must have the same PIDs, the same start codes, and the same audio/video properties (that is, they must come from the same source or channel).
    Using "Convert to MPEG" before joining the files can be helpful, because it changes PIDs and start codes to a default value. The preferred method to join streams is to Copy one stream in MPEG Streamclip, open another stream and Paste it there. This method checks that the joined streams indeed are compatible. Another method is to put the MPEGs in the same folder, and rename them so that they sort as desired in list view. Then select them via MPEG Streamclip's "File/Open Files..." dialog box (Shift- or Command-click to select multiple MPEGs). Then choose "Edit/Fix Timecode Breaks". After this MPEG Streamclip should report the combined length of all MPEGs (check the Log Window if you want to know whether any timecode breaks were found). Then choose "File/Convert to MPEG... or /Save As..." to save them in a single file. If the video transition between two files looks bad, you can use the Cut command to improve it. You can join very different and incompatible MPEGs with this latter method so the end result is not guaranteed to work.
    MPEG Streamclip can also edit MPEG files. Just set In/Out points (with I/O keys), Cut unwanted material off and choose "File/Convert to MPEG...". You can also Cut/Copy selections to other parts of the same stream or open another compatible stream and Paste it there. Shift-dragging the playhead can also be used to define a selection. Option + arrow keys jump to the beginning/end or In/Out points. You can use the Trim-command to more closely see a part of the video before cutting, then choose Revert Trimming to see all material. JKL-keys can be used to enable fast forward or reverse playing. The scroll wheel works also; with the Option key it scrolls 1 second per click. See the manual for more details on how to jump in single frame, GOP, 1 second, 10 second or 1 minute chunks when searching a specific spot in the video.
    Editing and trimming can be accurate only if In and Out are both on keyframes because MPEG Streamclip edits to the GOP, not to the frame. For DVD and (XS)VCD the maximum GOP size is PAL 15 and NTSC 18 frames, so the editing accuracy can be up to about 0.6 seconds. You can advance to the previous or next keyframe (i.e. I-frame, the beginning of each GOP or Group Of Pictures) with the Up/Down arrow keys -- you can also use the Edit/Go to Keyframe command to see where the In and Out points really are when editing (the In point is included in the selection, the Out point is not included). Shift + Up/Down arrow keys allow fine-tuning the selection to the GOP.
    Sue

  • How do I combine two user iPhoto files into one...keeps blocking the pics between users

    How do I combine two user iPhoto files into one...keeps blocking the pics between users on the same Mac?

    Put the library on an external hard drive that is formatted as shown in this screenshot:
    OT

Maybe you are looking for

  • Cancel cannot save to the file because it is in use

    Hi guys, From a couple of days ago i cannot export ANY pdf file in InDesign withouth the "cannot save to the file because it is in use by one or more background tasks". It seems there is a "temporary files" are saving. So the trick is to delete the f

  • Can I use the wizards to build a form that submits multiple checkboxes as an array?

    I could do this by hand, but for maintenance ease would prefer that the toolkit understand all my forms. Has anyone else figured out how to do this? Here's the scenario: On page load, a query is used to get a recordset that builds a form representing

  • Flash player not loading websites like pandora or memrise

    On those websites, the flash player just continues to load until the website times out. I've done the pandora troubleshooting, and I've reinstalled the flash player multiple times. The only thing that worked for awhile was uninstalling and reinstalli

  • Problem with Scene navigation

    I am using Flash 8 to develop mobile applications for Nokai 6600. I have three scenes in my FLA file and i am using the navigation keys to navigate to the scenes. When I test my application in the emulator, the first and second scenes are working pro

  • Checkpoint not complete in DB13

    Hi all, I'm getting this warning message every day in the checkDB job of DB13 : BR0976W Database message alert - level: WARNING, line: 193239, time: 2008-02-13 13.01.39, message: Checkpoint not complete