[AI CC-CC2022] Экспорт артбордов, помогите изменить скрипт

  • Автор темы Автор темы AnyLila
  • Дата начала Дата начала

AnyLila

Участник
Топикстартер
Сообщения
12
Реакции
0
Здравствуйте, знающие люди, помогите подправить скрипт, что бы экспортировалась каждая монтажная область в отдельный файл...т.е. из трех допустим, артбордов получилось на выходе 3 EPS и 3jpeg файла...а не один где все вместе...вот код:
Код:
var Doc;           
var fileType,  targetFile, targetFile1, jpgExportOpts, epsSaveOpts;
var Name;           
var name1;             
var pathName;           
var destFolder;           
var width, height;       
var statusMsg="\n";       

if (app.documents.length==0)
{
    alert("There are no documents opened. Nothing has been done.");
}else{

    Doc=activeDocument;
    
    Doc.save();
    Name=Doc.name;
    
    
    // get size of the image in pixels
    width=Doc.visibleBounds[2]-Doc.visibleBounds[0];
    height=Doc.visibleBounds[1]-Doc.visibleBounds[3];
    
    
    // check if the filename has extension
    if (Name.indexOf('.') < 0) {
        name1 = Name;
    } else {
        var token = Name.lastIndexOf('.');
        name1 = Name.substring(0, token);
    }
    
    pathName=Doc.fullName+" "; // convert pathName to string. Otherwise lastIndexOf does not work
    token = pathName.lastIndexOf('/');
    destFolder = pathName.substring(0, token);
    
    
    ///////////////////////////////////////////////////////
    //
    //    Export JPGs
    //
    ///////////////////////////////////////////////////////
    
    
    
    
    fileType = ExportType.JPEG;
    
    // Call function getJPGOptions get the ExportOptionsJPEG for the files
    if (jpgExportOpts = getJPGOptions(4000, width, height ))
    {
    
        // Export as a big jpg
    
        targetFile = new File(destFolder + '/' + name1 + '-Ai10');
        Doc.exportFile( targetFile, fileType, jpgExportOpts );
        statusMsg+="4000 px JPG\t...\tOK\n"
    }else{
        statusMsg+="4000 px JPG\t...\tFailed\n"
    }
    
    
    ///////////////////////////////////////////////////////
    //
    //    Save as EPS
    //
    ///////////////////////////////////////////////////////

    // Call function getESPOptions get the EPSSaveOptions for the files
    epsSaveOpts = getEPSOptions("10");
    targetFile = new File(destFolder + '/' + name1 + "-Ai10.eps");
    Doc.saveAs(targetFile, epsSaveOpts);
    statusMsg+="EPS Ai10\t\t...\tOK\n"

    // Now EPS file is active. Reopen Ai file
    Doc.close();
    targetFile1 = new File(destFolder + '/' + name1 + ".ai");
    Doc=app.open(targetFile1);
            
    

    statusMsg+="\nFor updates subscribe: http://oksancia.com/feed"
    
    alert( 'SaveForStocks-10\nThe following files were saved to:\n' + destFolder +'\n' + statusMsg);
    
    
    
}


/*********************************************************

getEPSOptions: Function to set the EPS saving options of the
files using the EPSSaveOptions object.

**********************************************************/

function getEPSOptions(compatibility)
{
    // Create the EPSSaveOptions object to set the PDF options
    var epsSaveOpts = new EPSSaveOptions();
    
    // Setting EPSSaveOptions properties. Please see the JavaScript Reference
    // for a description of these properties.
    if (compatibility=="10") {
        epsSaveOpts.compatibility= Compatibility.ILLUSTRATOR10;
    }else{
        epsSaveOpts.compatibility= Compatibility.ILLUSTRATOR8;
    }
    epsSaveOpts.includeDocumentThumbnails = true;
    epsSaveOpts.postScript = EPSPostScriptLevelEnum.LEVEL2;
    epsSaveOpts.preview = EPSPreview.COLORTIFF; //default
    
    return epsSaveOpts;
}

/*********************************************************

getJPGOptions: Function to set the JPG saving options of the
files using the EPSSaveOptions object.

**********************************************************/

function getJPGOptions(maxSize,width,height)
{
    var scaling;
    // Create the ExportOptionsJPEG object to set the JPG options
    var jpgExportOpts = new ExportOptionsJPEG();
    
    // Setting ExportOptionsJPEG properties. Please see the JavaScript Reference
    // for a description of these properties.
    jpgExportOpts.antiAliasing = true;
    jpgExportOpts.optimization = true;
    jpgExportOpts.qualitySetting = 100
    jpgExportOptions.artBoardClipping = true;;

    if (width>height)
    {
        scaling=maxSize/width * 100;
    }else{
        scaling=maxSize/height *100;
    }

    if (scaling>776.19)
    {
        var needed=Math.round(scaling/776.19*10)/10;
        alert ("Warning!\n\nThe image is too small and due to the Illustrator limitations could not be resized to " + maxSize + "px.\n"+ "Please scale the image by at least " + needed + " times.");
        return 0;       
    }


    jpgExportOpts.horizontalScale = scaling;
    jpgExportOpts.verticalScale = scaling;


    return jpgExportOpts;
}
 
для EPS после
Код:
epsSaveOpts.preview = EPSPreview.COLORTIFF; //default

добавьте

Код:
epsSaveOpts.saveMultipleArtboards = true;

вроде должно помочь
с JPG навскидку не помню )
 
  • Спасибо
Реакции: dumbm1 и _MBK_
Ура ура ура!!! с EPS работает!!!! СПАСИБО!!!!!! осталось с Jpeg разобраться....
 
Хелп, как же для Jpeg артборды выставить???
 
Секцию Export JPGs
можно заменить на цикл по артбордам:

Код:
    for (var i = 0; i < Doc.artboards.length; i++) {
      var obj = Doc.artboards[i];
      Doc.artboards.setActiveArtboardIndex(i);
      fileType = ExportType.JPEG;
      // Call function getJPGOptions get the ExportOptionsJPEG for the files
      if (jpgExportOpts = getJPGOptions(4000, width, height)) {
        // Export as a big jpg
        targetFile = new File(destFolder + '/' + name1 + '-Ai10-' + (i + 1));
        Doc.exportFile(targetFile, fileType, jpgExportOpts);
        statusMsg += "4000 px JPG\t...\tOK\n"
      } else {
        statusMsg += "4000 px JPG\t...\tFailed\n"
      }
    }
 
  • Спасибо
Реакции: Skvoznyak
и ещё там ошибка функции getJPGOptions:
вместо
Код:
jpgExportOptions.artBoardClipping = true;
должно быть
Код:
jpgExportOpts.artBoardClipping = true;
 
  • Спасибо
Реакции: Skvoznyak
Секцию Export JPGs
можно заменить на цикл по артбордам:

Код:
    for (var i = 0; i < Doc.artboards.length; i++) {
      var obj = Doc.artboards[i];
      Doc.artboards.setActiveArtboardIndex(i);
      fileType = ExportType.JPEG;
      // Call function getJPGOptions get the ExportOptionsJPEG for the files
      if (jpgExportOpts = getJPGOptions(4000, width, height)) {
        // Export as a big jpg
        targetFile = new File(destFolder + '/' + name1 + '-Ai10-' + (i + 1));
        Doc.exportFile(targetFile, fileType, jpgExportOpts);
        statusMsg += "4000 px JPG\t...\tOK\n"
      } else {
        statusMsg += "4000 px JPG\t...\tFailed\n"
      }
    }
сохраняет, но все артборды...т.е. если три артборда, то на выходе три Jpeg и в каждом все три артборда
 
я вот не вижу что-то опций для JPG задавать artboard.
либо удалять их по очереди, либо из экспортированных ранее EPS делать, что-ли...
 
Да я уже исправила ошибочку, спасибо, вот правильный уже с "EPS изменениями" осталось jpeg допилить....
Код:
var Doc;          
var fileType,  targetFile, targetFile1, jpgExportOpts, epsSaveOpts;
var Name;          
var name1;            
var pathName;          
var destFolder;          
var width, height;      
var statusMsg="\n";      


if (app.documents.length==0)
{
    alert("There are no documents opened. Nothing has been done.");
}else{

    Doc=activeDocument;
   
    Doc.save();
    Name=Doc.name;
   
   
    // get size of the image in pixels
    width=Doc.visibleBounds[2]-Doc.visibleBounds[0];
    height=Doc.visibleBounds[1]-Doc.visibleBounds[3];
   
   
    // check if the filename has extension
    if (Name.indexOf('.') < 0) {
        name1 = Name;
    } else {
        var token = Name.lastIndexOf('.');
        name1 = Name.substring(0, token);
    }
   
    pathName=Doc.fullName+" "; // convert pathName to string. Otherwise lastIndexOf does not work
    token = pathName.lastIndexOf('/');
    destFolder = pathName.substring(0, token);
   
   
    ///////////////////////////////////////////////////////
    //
    //    Export JPGs
    //
    ///////////////////////////////////////////////////////
   
   
   
   
    fileType = ExportType.JPEG;
   
    // Call function getJPGOptions get the ExportOptionsJPEG for the files
    if (jpgExportOpts = getJPGOptions(4000, width, height ))
    {
   
        // Export as a big jpg
   
        targetFile = new File(destFolder + '/' + name1 + '-Ai10');
        Doc.exportFile( targetFile, fileType, jpgExportOpts );
        statusMsg+="4000 px JPG\t...\tOK\n"
    }else{
        statusMsg+="4000 px JPG\t...\tFailed\n"
    }
   
   
    ///////////////////////////////////////////////////////
    //
    //    Save as EPS
    //
    ///////////////////////////////////////////////////////

    // Call function getESPOptions get the EPSSaveOptions for the files
    epsSaveOpts = getEPSOptions("10");
    targetFile = new File(destFolder + '/' + name1 + "-Ai10.eps");
    Doc.saveAs(targetFile, epsSaveOpts);
    statusMsg+="EPS Ai10\t\t...\tOK\n"

    // Now EPS file is active. Reopen Ai file
    Doc.close();
    targetFile1 = new File(destFolder + '/' + name1 + ".ai");
    Doc=app.open(targetFile1);
           
   

    statusMsg+="\nFor updates subscribe: http://oksancia.com/feed"
   
    alert( 'SaveForStocks-10\nThe following files were saved to:\n' + destFolder +'\n' + statusMsg);
   
   
   
}


/*********************************************************

getEPSOptions: Function to set the EPS saving options of the
files using the EPSSaveOptions object.

**********************************************************/

function getEPSOptions(compatibility)
{
    // Create the EPSSaveOptions object to set the PDF options
    var epsSaveOpts = new EPSSaveOptions();
   
    // Setting EPSSaveOptions properties. Please see the JavaScript Reference
    // for a description of these properties.
    if (compatibility=="10") {
        epsSaveOpts.compatibility= Compatibility.ILLUSTRATOR10;
    }else{
        epsSaveOpts.compatibility= Compatibility.ILLUSTRATOR8;
    }
    epsSaveOpts.includeDocumentThumbnails = true;
    epsSaveOpts.postScript = EPSPostScriptLevelEnum.LEVEL2;
    epsSaveOpts.preview = EPSPreview.None; //default
    epsSaveOpts.saveMultipleArtboards = true;
   
    return epsSaveOpts;
}

/*********************************************************

getJPGOptions: Function to set the JPG saving options of the
files using the EPSSaveOptions object.

**********************************************************/

function getJPGOptions(maxSize,width,height)
{
    var scaling;
    // Create the ExportOptionsJPEG object to set the JPG options
    var jpgExportOpts = new ExportOptionsJPEG();
   
    // Setting ExportOptionsJPEG properties. Please see the JavaScript Reference
    // for a description of these properties.
    jpgExportOpts.antiAliasing = true;
    jpgExportOpts.optimization = true;
    jpgExportOpts.qualitySetting = 100
   

    if (width>height)
    {
        scaling=maxSize/width * 100;
    }else{
        scaling=maxSize/height *100;
    }

    if (scaling>776.19)
    {
        var needed=Math.round(scaling/776.19*10)/10;
        alert ("Warning!\n\nThe image is too small and due to the Illustrator limitations could not be resized to " + maxSize + "px.\n"+ "Please scale the image by at least " + needed + " times.");
        return 0;      
    }


    jpgExportOpts.horizontalScale = scaling;
    jpgExportOpts.verticalScale = scaling;


    return jpgExportOpts;
}
 
возьмите исправленный
Код:
(function f() {
  var Doc;
  var fileType, targetFile, targetFile1, jpgExportOpts, epsSaveOpts;
  var Name;
  var name1;
  var pathName;
  var destFolder;
  var width, height;
  var statusMsg        = "\n";
  var userInteract     = userInteractionLevel;
  userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;

  if (app.documents.length == 0) {
    alert("There are no documents opened. Nothing has been done.");
  } else {

    Doc = activeDocument;

    Doc.save();
    Name = Doc.name;

    // get size of the image in pixels
    width  = Doc.visibleBounds[2] - Doc.visibleBounds[0];
    height = Doc.visibleBounds[1] - Doc.visibleBounds[3];

    // check if the filename has extension
    if (Name.indexOf('.') < 0) {
      name1 = Name;
    } else {
      var token = Name.lastIndexOf('.');
      name1     = Name.substring(0, token);
    }

    pathName   = Doc.fullName + " "; // convert pathName to string. Otherwise lastIndexOf does not work
    token      = pathName.lastIndexOf('/');
    destFolder = pathName.substring(0, token);

    ///////////////////////////////////////////////////////
    //
    //    Export JPGs
    //
    ///////////////////////////////////////////////////////
    for (var i = 0; i < Doc.artboards.length; i++) {
      var obj = Doc.artboards[i];
      Doc.artboards.setActiveArtboardIndex(i);
      fileType = ExportType.JPEG;
      // Call function getJPGOptions get the ExportOptionsJPEG for the files
      if (jpgExportOpts = getJPGOptions(4000, width, height)) {
        // Export as a big jpg
        targetFile = new File(destFolder + '/' + name1 + '-Ai10-' + (i + 1));
        Doc.exportFile(targetFile, fileType, jpgExportOpts);
        statusMsg += "4000 px JPG\t...\tOK\n"
      } else {
        statusMsg += "4000 px JPG\t...\tFailed\n"
      }
    }

    ///////////////////////////////////////////////////////
    //
    //    Save as EPS
    //
    ///////////////////////////////////////////////////////

    // Call function getESPOptions get the EPSSaveOptions for the files
    epsSaveOpts = getEPSOptions("10");
    targetFile  = new File(destFolder + '/' + name1 + "-Ai10.eps");
    Doc.saveAs(targetFile, epsSaveOpts);
    statusMsg += "EPS Ai10\t\t...\tOK\n"

    // Now EPS file is active. Reopen Ai file
    Doc.close();
    targetFile1 = new File(destFolder + '/' + name1 + ".ai");
    Doc         = app.open(targetFile1);

    statusMsg += "\nFor updates subscribe: http://oksancia.com/feed"

    alert('SaveForStocks-10\nThe following files were saved to:\n' + destFolder + '\n' + statusMsg);

  }

  userInteractionLevel = userInteract;

  /*********************************************************

   getEPSOptions: Function to set the EPS saving options of the
   files using the EPSSaveOptions object.

   **********************************************************/

  function getEPSOptions(compatibility) {
    // Create the EPSSaveOptions object to set the PDF options
    var epsSaveOpts = new EPSSaveOptions();

    // Setting EPSSaveOptions properties. Please see the JavaScript Reference
    // for a description of these properties.
    if (compatibility == "10") {
      epsSaveOpts.compatibility = Compatibility.ILLUSTRATOR10;
    } else {
      epsSaveOpts.compatibility = Compatibility.ILLUSTRATOR8;
    }
    epsSaveOpts.includeDocumentThumbnails = true;
    epsSaveOpts.postScript                = EPSPostScriptLevelEnum.LEVEL2;
    epsSaveOpts.preview                   = EPSPreview.COLORTIFF; //default
    epsSaveOpts.saveMultipleArtboards     = true;

    return epsSaveOpts;
  }

  /*********************************************************

   getJPGOptions: Function to set the JPG saving options of the
   files using the EPSSaveOptions object.

   **********************************************************/

  function getJPGOptions(maxSize, width, height) {
    var scaling;
    // Create the ExportOptionsJPEG object to set the JPG options
    var jpgExportOpts = new ExportOptionsJPEG();

    // Setting ExportOptionsJPEG properties. Please see the JavaScript Reference
    // for a description of these properties.
    jpgExportOpts.antiAliasing     = true;
    jpgExportOpts.optimization     = true;
    jpgExportOpts.qualitySetting   = 100
    jpgExportOpts.artBoardClipping = true;

    if (width > height) {
      scaling = maxSize / width * 100;
    } else {
      scaling = maxSize / height * 100;
    }

    if (scaling > 776.19) {
      var needed = Math.round(scaling / 776.19 * 10) / 10;
      alert("Warning!\n\nThe image is too small and due to the Illustrator limitations could not be resized to " + maxSize + "px.\n" + "Please scale the image by at least " + needed + " times.");
      return 0;
    }

    jpgExportOpts.horizontalScale = scaling;
    jpgExportOpts.verticalScale   = scaling;

    return jpgExportOpts;
  }
}());
 
Вот уже сохраняет, ура! правда не по заданному размеру (4000px), а меньше
 
вот вроде поправил, должно сработать, тестируйте (замените в последнем моём коде секцию Export JPGs):
Код:
    ///////////////////////////////////////////////////////
    //
    //    Export JPGs
    //
    ///////////////////////////////////////////////////////
    for (var i = 0; i < Doc.artboards.length; i++) {

      var obj = Doc.artboards[i];
      Doc.artboards.setActiveArtboardIndex(i);
      fileType       = ExportType.JPEG;

      var artbWidth  = obj.artboardRect[2] - obj.artboardRect[0];
      var artbHeight = obj.artboardRect[1] - obj.artboardRect[3];

      // Call function getJPGOptions get the ExportOptionsJPEG for the files
      if (jpgExportOpts = getJPGOptions(4000, artbWidth, artbHeight)) {
        // Export as a big jpg
        targetFile = new File(destFolder + '/' + name1 + '-Ai10-' + (i + 1));
        Doc.exportFile(targetFile, fileType, jpgExportOpts);
        statusMsg += "4000 px JPG\t...\tOK\n"
      } else {
        statusMsg += "4000 px JPG\t...\tFailed\n"
      }
    }
Но маленькие артборды не экспортирует, так скрипт изначально написан. Это Вам критично?
 
а так сохраняет только первый артборд, остальные не экспартирует
 
а пишет что в отчёте?
 
вот эта версия у меня экспортирует всё (при условии, что артборды достаточно большие):
Код:
//@target illustrator
(function f() {
  var Doc;
  var fileType, targetFile, targetFile1, jpgExportOpts, epsSaveOpts;
  var Name;
  var name1;
  var pathName;
  var destFolder;
  var width, height;
  var statusMsg        = "\n";
  var userInteract     = userInteractionLevel;
  userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;

  if (app.documents.length == 0) {
    alert("There are no documents opened. Nothing has been done.");
  } else {

    Doc = activeDocument;

    Doc.save();
    Name = Doc.name;

    // get size of the image in pixels
    width  = Doc.visibleBounds[2] - Doc.visibleBounds[0];
    height = Doc.visibleBounds[1] - Doc.visibleBounds[3];

    // check if the filename has extension
    if (Name.indexOf('.') < 0) {
      name1 = Name;
    } else {
      var token = Name.lastIndexOf('.');
      name1     = Name.substring(0, token);
    }

    pathName   = Doc.fullName + " "; // convert pathName to string. Otherwise lastIndexOf does not work
    token      = pathName.lastIndexOf('/');
    destFolder = pathName.substring(0, token);

    ///////////////////////////////////////////////////////
    //
    //    Export JPGs
    //
    ///////////////////////////////////////////////////////
    for (var i = 0; i < Doc.artboards.length; i++) {

      var obj = Doc.artboards[i];
      Doc.artboards.setActiveArtboardIndex(i);
      fileType       = ExportType.JPEG;
      var artbWidth  = obj.artboardRect[2] - obj.artboardRect[0];
      var artbHeight = obj.artboardRect[1] - obj.artboardRect[3];
      // Call function getJPGOptions get the ExportOptionsJPEG for the files
      if (jpgExportOpts = getJPGOptions(4000, artbWidth, artbHeight)) {
        // Export as a big jpg
        targetFile = new File(destFolder + '/' + name1 + '-Ai10-' + (i + 1));
        Doc.exportFile(targetFile, fileType, jpgExportOpts);
        statusMsg += "4000 px JPG\t...\tOK\n"
      } else {
        statusMsg += "4000 px JPG\t...\tFailed\n"
      }
    }

    ///////////////////////////////////////////////////////
    //
    //    Save as EPS
    //
    ///////////////////////////////////////////////////////

    // Call function getESPOptions get the EPSSaveOptions for the files
    epsSaveOpts = getEPSOptions("10");
    targetFile  = new File(destFolder + '/' + name1 + "-Ai10.eps");
    Doc.saveAs(targetFile, epsSaveOpts);
    statusMsg += "EPS Ai10\t\t...\tOK\n"

    // Now EPS file is active. Reopen Ai file
    Doc.close();
    targetFile1 = new File(destFolder + '/' + name1 + ".ai");
    Doc         = app.open(targetFile1);

    statusMsg += "\nFor updates subscribe: http://oksancia.com/feed"

    alert('SaveForStocks-10\nThe following files were saved to:\n' + destFolder + '\n' + statusMsg);

  }

  userInteractionLevel = userInteract;

  /*********************************************************

   getEPSOptions: Function to set the EPS saving options of the
   files using the EPSSaveOptions object.

   **********************************************************/

  function getEPSOptions(compatibility) {
    // Create the EPSSaveOptions object to set the PDF options
    var epsSaveOpts = new EPSSaveOptions();

    // Setting EPSSaveOptions properties. Please see the JavaScript Reference
    // for a description of these properties.
    if (compatibility == "10") {
      epsSaveOpts.compatibility = Compatibility.ILLUSTRATOR10;
    } else {
      epsSaveOpts.compatibility = Compatibility.ILLUSTRATOR8;
    }
    epsSaveOpts.includeDocumentThumbnails = true;
    epsSaveOpts.postScript                = EPSPostScriptLevelEnum.LEVEL2;
    epsSaveOpts.preview                   = EPSPreview.COLORTIFF; //default
    epsSaveOpts.saveMultipleArtboards     = true;

    return epsSaveOpts;
  }

  /*********************************************************

   getJPGOptions: Function to set the JPG saving options of the
   files using the EPSSaveOptions object.

   **********************************************************/

  function getJPGOptions(maxSize, width, height) {
    var scaling;
    // Create the ExportOptionsJPEG object to set the JPG options
    var jpgExportOpts = new ExportOptionsJPEG();

    // Setting ExportOptionsJPEG properties. Please see the JavaScript Reference
    // for a description of these properties.
    jpgExportOpts.antiAliasing     = true;
    jpgExportOpts.optimization     = true;
    jpgExportOpts.qualitySetting   = 100
    jpgExportOpts.artBoardClipping = true;

    if (width > height) {
      scaling = maxSize / width * 100;
    } else {
      scaling = maxSize / height * 100;
    }

    if (scaling > 776.19) {
      var needed = Math.round(scaling / 776.19 * 10) / 10;
      alert("Warning!\n\nThe image is too small and due to the Illustrator limitations could not be resized to " + maxSize + "px.\n" + "Please scale the image by at least " + needed + " times.");
      return 0;
    }

    jpgExportOpts.horizontalScale = scaling;
    jpgExportOpts.verticalScale   = scaling;

    return jpgExportOpts;
  }
}());
 
возьмите исправленный
Код:
(function f() {
  var Doc;
  var fileType, targetFile, targetFile1, jpgExportOpts, epsSaveOpts;
  var Name;
  var name1;
  var pathName;
  var destFolder;
  var width, height;
  var statusMsg        = "\n";
  var userInteract     = userInteractionLevel;
  userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;

  if (app.documents.length == 0) {
    alert("There are no documents opened. Nothing has been done.");
  } else {

    Doc = activeDocument;

    Doc.save();
    Name = Doc.name;

    // get size of the image in pixels
    width  = Doc.visibleBounds[2] - Doc.visibleBounds[0];
    height = Doc.visibleBounds[1] - Doc.visibleBounds[3];

    // check if the filename has extension
    if (Name.indexOf('.') < 0) {
      name1 = Name;
    } else {
      var token = Name.lastIndexOf('.');
      name1     = Name.substring(0, token);
    }

    pathName   = Doc.fullName + " "; // convert pathName to string. Otherwise lastIndexOf does not work
    token      = pathName.lastIndexOf('/');
    destFolder = pathName.substring(0, token);

    ///////////////////////////////////////////////////////
    //
    //    Export JPGs
    //
    ///////////////////////////////////////////////////////
    for (var i = 0; i < Doc.artboards.length; i++) {
      var obj = Doc.artboards[i];
      Doc.artboards.setActiveArtboardIndex(i);
      fileType = ExportType.JPEG;
      // Call function getJPGOptions get the ExportOptionsJPEG for the files
      if (jpgExportOpts = getJPGOptions(4000, width, height)) {
        // Export as a big jpg
        targetFile = new File(destFolder + '/' + name1 + '-Ai10-' + (i + 1));
        Doc.exportFile(targetFile, fileType, jpgExportOpts);
        statusMsg += "4000 px JPG\t...\tOK\n"
      } else {
        statusMsg += "4000 px JPG\t...\tFailed\n"
      }
    }

    ///////////////////////////////////////////////////////
    //
    //    Save as EPS
    //
    ///////////////////////////////////////////////////////

    // Call function getESPOptions get the EPSSaveOptions for the files
    epsSaveOpts = getEPSOptions("10");
    targetFile  = new File(destFolder + '/' + name1 + "-Ai10.eps");
    Doc.saveAs(targetFile, epsSaveOpts);
    statusMsg += "EPS Ai10\t\t...\tOK\n"

    // Now EPS file is active. Reopen Ai file
    Doc.close();
    targetFile1 = new File(destFolder + '/' + name1 + ".ai");
    Doc         = app.open(targetFile1);

    statusMsg += "\nFor updates subscribe: http://oksancia.com/feed"

    alert('SaveForStocks-10\nThe following files were saved to:\n' + destFolder + '\n' + statusMsg);

  }

  userInteractionLevel = userInteract;

  /*********************************************************

   getEPSOptions: Function to set the EPS saving options of the
   files using the EPSSaveOptions object.

   **********************************************************/

  function getEPSOptions(compatibility) {
    // Create the EPSSaveOptions object to set the PDF options
    var epsSaveOpts = new EPSSaveOptions();

    // Setting EPSSaveOptions properties. Please see the JavaScript Reference
    // for a description of these properties.
    if (compatibility == "10") {
      epsSaveOpts.compatibility = Compatibility.ILLUSTRATOR10;
    } else {
      epsSaveOpts.compatibility = Compatibility.ILLUSTRATOR8;
    }
    epsSaveOpts.includeDocumentThumbnails = true;
    epsSaveOpts.postScript                = EPSPostScriptLevelEnum.LEVEL2;
    epsSaveOpts.preview                   = EPSPreview.COLORTIFF; //default
    epsSaveOpts.saveMultipleArtboards     = true;

    return epsSaveOpts;
  }

  /*********************************************************

   getJPGOptions: Function to set the JPG saving options of the
   files using the EPSSaveOptions object.

   **********************************************************/

  function getJPGOptions(maxSize, width, height) {
    var scaling;
    // Create the ExportOptionsJPEG object to set the JPG options
    var jpgExportOpts = new ExportOptionsJPEG();

    // Setting ExportOptionsJPEG properties. Please see the JavaScript Reference
    // for a description of these properties.
    jpgExportOpts.antiAliasing     = true;
    jpgExportOpts.optimization     = true;
    jpgExportOpts.qualitySetting   = 100
    jpgExportOpts.artBoardClipping = true;

    if (width > height) {
      scaling = maxSize / width * 100;
    } else {
      scaling = maxSize / height * 100;
    }

    if (scaling > 776.19) {
      var needed = Math.round(scaling / 776.19 * 10) / 10;
      alert("Warning!\n\nThe image is too small and due to the Illustrator limitations could not be resized to " + maxSize + "px.\n" + "Please scale the image by at least " + needed + " times.");
      return 0;
    }

    jpgExportOpts.horizontalScale = scaling;
    jpgExportOpts.verticalScale   = scaling;

    return jpgExportOpts;
  }
}());
скрипт получается задает сторону в 4000 px всех вместе взятых артбордов, если поставить значение больше 4000, то и конечный файл будет больше, так можно конечно вычислить сколько задавать, что бы получился нужный размер Jpeg, но комп у меня конечно от таких цифр "задумывается" на порядок....а может я ошибаюсь...может это и не влияет на производительность....так мысли...
 
у меня артборды по 700px
 
нет, вот эта версия задаёт 4000 для каждого отдельного артборда