Skip to main content
mi5studio
Participant
July 11, 2025
Answered

Create múltiple blank files at once from ilustrator

  • July 11, 2025
  • 2 replies
  • 548 views

Hi everyone,

I wanted to ask if anyone knows how to create multiple blank Illustrator files from a CSV, using the following parameters:

  • File name

  • CMYK color mode

  • Width in cm

  • Height in cm

So the idea would be to provide a list of 500 items, and have the program automatically generate the files with the dimensions specified in the CSV.

Many thanks in advance!

Correct answer Sergey Osokin

Because AI assistants invent non-existent methods. If you don't know where to look, it's impossible to debug scripts. There is no way in Adobe's documentation to set Bleed for Document Setup in ExtendScript.

//@target illustrator

(function (){
  // Open CSV
  var csvFile = File.openDialog("Select your CSV file", "*.csv");
  if (!csvFile) {
      alert("No CSV selected. Exiting.");
      exit();
  }
  var lines = readCSV(csvFile);

  // Ask for output folder
  var outFolder = Folder.selectDialog("Choose folder to save AI files");
  if (!outFolder) {
      alert("No output folder. Exiting.");
      exit();
  }

  // Constants
  var CM_TO_POINTS = 72 / 2.54; // 28.3464567

  // Process each line after header
  for (var i = 1; i < lines.length; i++) {
      var row = trim(lines[i]);
      if (!row) continue; // skip empty lines

      var cols = row.split(",");
      var docName = cols[0].replace(/\"/g, '');
      var wCm = parseFloat(cols[1].replace(/\"/g, ''));
      var hCm = parseFloat(cols[2].replace(/\"/g, ''));

      // Create new CMYK document in cm
      var docPreset = new DocumentPreset;
          docPreset.width = wCm * CM_TO_POINTS;
          docPreset.height = hCm * CM_TO_POINTS;
          docPreset.colorMode = DocumentColorSpace.CMYK
          docPreset.title = docName;
          docPreset.units = RulerUnits.Centimeters;
          docPreset.name = docName;
      var doc = app.documents.addDocument(DocumentColorSpace.CMYK, docPreset);

      // Save as .ai
      var saveOpts = new IllustratorSaveOptions();
      saveOpts.pdfCompatible = true;
      var saveFile = new File(outFolder.fsName + "/" + docName + ".ai");
      doc.saveAs(saveFile, saveOpts);

      // Close without prompting
      doc.close(SaveOptions.DONOTSAVECHANGES);
  }

  // Notify when done
  alert("Created " + (lines.length - 1) + " files in " + outFolder.fsName);

  function readCSV(f) {
    f.encoding = 'UTF-8';
    f.open('r');
    var s = f.read();
    f.close();
    return s.split(/\r\n|\n/);
  }

  function trim(str) {
    return str.replace(/^\s+|\s+$/g, '');
  }
})();

 

2 replies

Ares Hovhannesyan
Community Expert
Community Expert
July 11, 2025

Microsoft Capilot suggests this. But I diden't test it.

Automating Illustrator: Mass-Generate Documents from CSV

You can use an ExtendScript (JavaScript) script inside Illustrator to read a CSV and spin out 500 (or more) blank AI files—each in CMYK with your custom dimensions and filenames. Below is a step-by-step guide plus a ready-to-use script.


1. Prepare Your CSV

Make sure your CSV uses UTF-8 encoding and has a header row:

FileName,Width_cm,Height_cm
Brochure_A4,21,29.7
Poster_Large,50,70
… up to 500 entries …
  • No extra commas in names
  • Decimal separator is a dot (.)
  • Save it somewhere easy to find (e.g., C:\Temp\artboards.csv)

2. Place & Load the Script

  1. Open your file explorer and navigate to
    C:\Program Files\Adobe\Adobe Illustrator <version>\Presets\en_US\Scripts\
  2. Create a new file named BatchNewFromCSV.jsx
  3. Paste the ExtendScript code (below) into it and save.

Illustrator will auto-discover scripts in this folder when relaunched.


3. ExtendScript Code

#target illustrator

// Open CSV
var csvFile = File.openDialog("Select your CSV file", "*.csv");
if (!csvFile) {
    alert("No CSV selected. Exiting.");
    exit();
}
csvFile.open("r");
var lines = csvFile.read().split("\r\n");
csvFile.close();

// Ask for output folder
var outFolder = Folder.selectDialog("Choose folder to save AI files");
if (!outFolder) {
    alert("No output folder. Exiting.");
    exit();
}

// Constants
var CM_TO_POINTS = 72 / 2.54; // 28.3464567

// Process each line after header
for (var i = 1; i < lines.length; i++) {
    var row = lines[i].trim();
    if (!row) continue; // skip empty lines

    var cols = row.split(",");
    var docName = cols[0];
    var wCm = parseFloat(cols[1]);
    var hCm = parseFloat(cols[2]);

    // Create new CMYK document in cm
    var doc = app.documents.add(
        DocumentColorSpace.CMYK,
        wCm * CM_TO_POINTS,
        hCm * CM_TO_POINTS
    );

    // Save as .ai
    var saveFile = new File(outFolder.fsName + "/" + docName + ".ai");
    var saveOpts = new IllustratorSaveOptions();
    saveOpts.pdfCompatible = true;
    doc.saveAs(saveFile, saveOpts);

    // Close without prompting
    doc.close(SaveOptions.DONOTSAVECHANGES);
}

// Notify when done
alert("Created " + (lines.length - 1) + " files in " + outFolder.fsName);

4. Run the Script

  1. Restart Illustrator
  2. Go to File > Scripts > BatchNewFromCSV
  3. Choose your CSV, then the output folder
  4. Watch the magic—empty CMYK AI files appear, sized & named per your CSV

5. Tips & Next Steps

  • For Windows users, you can also drag the .jsx onto Illustrator’s window to launch it
  • If your CSV includes complex names or extra columns, consider a more robust CSV parser
  • You can expand the script to add artboards, set bleed, or apply templates
  • To speed things up, split huge CSVs into chunks of 100–200 entries if you encounter timeouts

 

miguelp92628622
Participant
July 11, 2025

Thank you very much for your detailed explanation.
I followed the instructions carefully (on Mac) and when I run the script in Illustrator, it says:
"Created 0 files in /Users/myRoot..."

 

Is there somewhere I can find the error?

On the other hand once this works I will love to add bleed and maybe extra artworks to each file.

 

Best

Ares Hovhannesyan
Community Expert
Community Expert
July 12, 2025

Unfortunatly I get the same. Here what suggest Microsoft Capilot.

 

There could be a few reasons why your script shows “Created 0 files...” even though you expected files to be generated. Here’s a breakdown of possible causes and how you can troubleshoot:


🧩 1. Empty or Misread CSV File

  • The script might not be reading the CSV file correctly.
  • Check if the file has valid rows (besides the header).
  • Ensure proper path and permissions to read the file.

✅ Tip: Try printing the rows before file creation to confirm they're loaded.


📁 2. Incorrect File Path

  • If your script is supposed to write files in /Users/myRoot, it might lack write access.
  • Confirm that the path is correct and writable on your system.

✅ Tip: Use an absolute path or os.path.join() if coding in Python.


🔄 3. File Creation Logic Is Skipped

  • Your loop or condition that triggers file creation might not be executing.
  • Check if you’re filtering or skipping rows unintentionally.

✅ Tip: Add a log like print("Creating file for:", row['Artboard Name']) to debug.


🧪 4. Filename or Directory Conflicts

  • Sometimes the script avoids overwriting or can’t create duplicate names.
  • Make sure filenames are unique, and the folder exists or is created dynamically.

✅ Tip: Try adding timestamp suffixes for unique filenames.


 

Andy Tells Things
Community Expert
Community Expert
July 11, 2025

Hi there! As far as my knowledge goes, you cannot do something like this with built-in Illustrator tools. You could, however, create a script to do that for you. I've had really good experiences using AI to create Illustrator scripts in the past, and what you're asking seems pretty doable. Give it a try! Hope that helps! 🙂