Skip navigation
Currently Being Moderated

Ai Packaging Script

Apr 11, 2012 8:01 AM

Ok.. I'm sure this has been posted before (already searched, didn't find however), but does a file packaging script exist for AI? (one that collects all linked images and fonts and places them in one place) This would be IMMENSELY helpful to me if anyone can post a link to one or even be willing to write it.

 

OS: W7

AI Version: CS5

 

Thanks in advance!

 
Replies
  • Currently Being Moderated
    Apr 11, 2012 8:21 AM   in reply to Andymc7

    Hi, on the "more like this" panel to your right there another post, see if it helps

     

    http://forums.adobe.com/message/4210592#4210592

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 11, 2012 11:55 AM   in reply to Andymc7

    in that thread, it is mentioned there's a script that ships with illustrator that collects the ai file and the placed images, but not the fonts.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 11, 2012 12:36 PM   in reply to Andymc7

    one possible reason is you might not be an administrator, even if you are. Close illustrator and right click on it and chose "run as administrator", then try running the script.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 19, 2012 12:06 PM   in reply to Andymc7

    Here is a package script I have been using. It collects linked files, but not fonts. Instead it ask whether or not you want to outline all text elements.

    Only tested on a Mac though. Good luck. // Pascal

     

    // This script exports a package of the currently active document.

    // Choose output folder, and indicate whether or not you want to

    // outline text elements.

     

     

    const FILE_SUFFIX = "-export";

    const ASSET_SUFFIX = "-assets";

    var doc = app.activeDocument;

    if (!doc.saved) doc.save();

    var original_file = doc.fullName;

     

     

     

     

    // create text outlines if desired.

    if (confirm("Create text outlines?", true)) { while (doc.textFrames.length != 0) { doc.textFrames[0].createOutline(); }}

     

     

     

     

    // collect all linked files

    var export_folder = Folder.selectDialog("Choose a folder to package into.");

    var arr = doc.name.split(".");

    var extension = "";

    if (arr.length>1) extension = "." + arr.pop();

    var filename = arr.join(".");

    var assets_folder = new Folder(export_folder + "/" + filename + ASSET_SUFFIX);

    if (assets_folder.exists || assets_folder.create()) {

              var i, in_file, out_file;

              for (i=0;i<doc.placedItems.length;i++) {

                        in_file = doc.placedItems[i].file;

                        out_file = File(assets_folder+"/"+in_file.name);

                        in_file.copy(out_file);

                        doc.placedItems[i].file = out_file;

              }

              for (i=0;i<doc.rasterItems.length;i++) {

                        if (doc.rasterItems[i].embedded) continue;

                        in_file = doc.rasterItems[i].file;

                        out_file = File(assets_folder+"/"+in_file.name);

                        in_file.copy(out_file);

                        doc.rasterItems[i].file = out_file;

              }

     

              // save as new file

              packaged_file = File(export_folder + "/" + filename + FILE_SUFFIX + extension);

              doc.saveAs(packaged_file);

              doc.close();

     

              // re-open the original file

              app.open(File(original_file));

     

    } else {

              alert("Unable to create the assets folder.");

    }

     
    |
    Mark as:
  • Currently Being Moderated
    May 9, 2012 1:36 PM   in reply to Andymc7

    Untested, but I think all you need to do is add a IllustratorSaveOption object:

     

         // save as new file
         packaged_file = File(export_folder + "/" + filename + FILE_SUFFIX + extension);
         var save_options = new IllustratorSaveOptions();
         save_options.embedICCProfile = true;
         save_options.pdfCompatible = false
         doc.saveAs(packaged_file, save_options);
         doc.close();
    

     

    Good luck. // p

     
    |
    Mark as:
  • Currently Being Moderated
    May 9, 2012 1:44 PM   in reply to Andymc7

    The real packaging script for AI is a Press-Ready or High Quality output PDF. It does everything that a script would do and everything is in one file.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 25, 2012 10:41 AM   in reply to pwever

    I apologize for my "noobiness"...

    How do we use this.

    I know how to use scripts but I am not sure how to use your text to apply your script.  Can you PM me the script file?

    I tried using the script console tool but didnt have much luck.

    Thanks!

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 13, 2012 4:06 AM   in reply to pwever

    hey pwever,

     

    Wow you're a lifesaver.. had the same problem as andymc7. Btw, do you know how I can into the script for it to not only save an ai. copy but also a pdf. and eps. copy while collecting? Thanks in advance.

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 24, 2012 8:24 PM   in reply to fuzzyteddy

    Fuzzyteddy,

    here is a version that should export an AI, PDF and EPS file.

    Hope it helps // p

     

    Download at https://www.dropbox.com/s/lomfrkj7rt94sqk/Package-extra.js

     

    or copy below.

     

    // This script exports a package of the currently active document.
    // Choose output folder, and indicate whether or not you want to 
    // outline text elements.
    
    const FILE_SUFFIX = "-export";
    const ASSET_SUFFIX = "-assets";
    var doc = app.activeDocument;
    if (!doc.saved) doc.save();
    var original_file = doc.fullName;
    
    
    // create text outlines if desired.
    if (confirm("Create text outlines?", true)) { while (doc.textFrames.length != 0) { doc.textFrames[0].createOutline(); }}
    
    
    // collect all linked files
    var export_folder = Folder.selectDialog("Choose a folder to package into.");
    var arr = doc.name.split(".");
    var extension = "";
    if (arr.length>1) extension = "." + arr.pop();
    var filename = arr.join(".");
    var assets_folder = new Folder(export_folder + "/" + filename + ASSET_SUFFIX);
    if (assets_folder.exists || assets_folder.create()) {
         var i, in_file, out_file;
         for (i=0;i<doc.placedItems.length;i++) {
              in_file = doc.placedItems[i].file;
              out_file = File(assets_folder+"/"+in_file.name);
              in_file.copy(out_file);
              doc.placedItems[i].file = out_file;
         }
         for (i=0;i<doc.rasterItems.length;i++) {
              if (doc.rasterItems[i].embedded) continue;
              in_file = doc.rasterItems[i].file;
              out_file = File(assets_folder+"/"+in_file.name);
              in_file.copy(out_file);
              doc.rasterItems[i].file = out_file;
         }
         
         // save as new Illustrator file
         packaged_file = File(export_folder + "/" + filename + FILE_SUFFIX + extension);
         doc.saveAs(packaged_file, this.getAIOptions() );
         
         // PDF export
        var pdf_target_file = File(export_folder + "/" + this.changeExtension(doc.name, ".pdf"));
        doc.saveAs( pdf_target_file, this.getPDFOptions() );
        
         // EPS export
         var eps_target_file = File(export_folder + "/" + this.changeExtension(doc.name, ".eps"));
         doc.saveAs( eps_target_file, this.getEPSOptions() );
         
         // close the document and re-open the original file
         doc.close();
         app.open(File(original_file));
         
    } else {
         alert("Unable to create the assets folder.");
    }
    
    function getAIOptions() {
         var options = new IllustratorSaveOptions();
         options.embedICCProfile = true;
         options.pdfCompatible = false;
         return options;
    }
         
    function getEPSOptions() {
         var options = new EPSSaveOptions();
         options.cmykPostScript = true;
         options.embedAllFonts = true;
         return options;
    }
    
    function getPDFOptions() {
         var options = new PDFSaveOptions();
        options.pDFPreset = "[Smallest File Size]";
         
        options.compatibility = PDFCompatibility.ACROBAT7;
        // general
        options.preserveEditability = false;
        options.generateThumbnails = false;
        options.optimization = true;
        options.viewAfterSaving = false;
        options.acrobatLayers = false;
        // compression
        options.compressArt = true;
        options.colorCompression = CompressionQuality.AUTOMATICJPEGMEDIUM;
        
         return options;
    }
    
    function changeExtension(filename, new_ext) {
        var new_name = "";
         if (filename.indexOf('.') < 0) {
              new_name = filename + new_ext;
         } else {
              var dot = filename.lastIndexOf('.');
              new_name += filename.substring(0, dot);
              new_name += new_ext;
         }
        return new_name;
    }
    
    
     
    |
    Mark as:
  • Currently Being Moderated
    Aug 29, 2012 9:03 AM   in reply to pwever

    Hi pwever,

     

    Thanks for creating the script for me... unfortunately my pc can't seem to run the javascript file but it runs visual basic scripts. Is there a way you can convert the current script to visual basic for me? You'd would be doing me a huge favour and I thank you in advance if you're free to help me

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 29, 2012 9:18 AM   in reply to fuzzyteddy

    What are you doing with the file…? The syntax is ExtendScript and should run on both platforms… At a glance I can't see anything that may be OS specific… IMO better to sort any issue than translate…

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 29, 2012 9:39 AM   in reply to pwever

    Hi pwever,

     

    Sorry, I copied the text wrongly... and totally missed the download link you posted... I've downloaded the file and it works perfectly.. Sorry for troubling you and Thanks a million for helping me with this script!

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 29, 2012 9:49 AM   in reply to fuzzyteddy

    That was easier me thinks… You can C&P from the forum but you need to save in plain text depending on what you use… AI will not see *.jsxbin

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points