Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Import Artboard names from list (csv file)?

Explorer ,
Jun 09, 2022 Jun 09, 2022

Are there any scripts or workarounds for importing a list of names to automatically update the Artboard names to match?

TOPICS
Import and export , Scripting
1.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jun 09, 2022 Jun 09, 2022

It is possible via a script but most of the users in this forum are not scripting. Here's a post in the scripting forum that discusses your topic in more detail. I hope it helps. https://community.adobe.com/t5/illustrator-discussions/script-to-import-csv-file-to-create-artboards-with-name-and-size/td-p/10440630

Translate
Adobe
Community Expert ,
Jun 09, 2022 Jun 09, 2022

It is possible via a script but most of the users in this forum are not scripting. Here's a post in the scripting forum that discusses your topic in more detail. I hope it helps. https://community.adobe.com/t5/illustrator-discussions/script-to-import-csv-file-to-create-artboards...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 09, 2022 Jun 09, 2022

Thanks!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 08, 2023 Apr 08, 2023

I have a related question - Is there a way, or a script, to export the list of artboard names?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 08, 2023 Apr 08, 2023

here you go, open a document before running the script

text file will be saved to the desktop

 

 

// write Artboard names to text file
// CarlosCanto 4/8/23
// https://community.adobe.com/t5/illustrator-discussions/import-artboard-names-from-list-csv-file/td-p/12994650

function main() {
    var abnames = getArtboardNames ();
    
    var f = File('~/Desktop/artboardNames.txt');
    
    writeToText (abnames.join("\n"), f);
}

main();

function getArtboardNames (names) {
    var idoc = app.activeDocument;
    var abnames = [];
    
    for (a=0; a<idoc.artboards.length; a++) {
        abnames.push(idoc.artboards[a].name);
    }

    return abnames;
}

function writeToText (str, f) {
    f.open('w');
    f.write(str);
    f.close();
}

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Apr 09, 2023 Apr 09, 2023

I made such a script too. But I also added two actions via boolean variable: either save names to txt file or read and rename from it. I also added an artboard index counter to start collecting names. I needed this to collect the names of new artboards in one document and also to rename only part of the artboards in another document.

 

 

 

// write or read Artboard names to text file
// CarlosCanto 4/8/23
// Modification: Sergey Osokin 4/11/23
// https://community.adobe.com/t5/illustrator-discussions/import-artboard-names-from-list-csv-file/td-p/12994650

function main() {
  var isSave = true; // Save or load artboard names to doc
  var startIdx = 0; // Save names starting from the index (first index = 0)
  var f = File(Folder.desktop + '/artboardNames.txt');

  if (!/illustrator/i.test(app.name)) {
    alert('Wrong application\nRun script from Adobe Illustrator', 'Script error');
    return false;
  }

  if (!documents.length) {
    alert('No documents\nOpen a document and try again', 'Script error');
    return false;
  }

  var doc = app.activeDocument;

  var win = new Window('dialog', 'Artboard Names to TXT');
  win.alignChildren = ['fill','top'];

  var actionGrp = win.add('group');
  actionGrp.alignChildren = ['left', 'center'];
  var saveRb = actionGrp.add('radiobutton', undefined, 'Save to file');
  saveRb.value = isSave;
  var applyRb = actionGrp.add('radiobutton', undefined, 'Apply from file');
  applyRb.value = !isSave;
  
  var idxGrp = win.add('group');
  idxGrp.alignChildren = ['left', 'center'];
  idxGrp.add('statictext', undefined, 'Start index (first is 0):');
  var idxInp = idxGrp.add('edittext', undefined, startIdx);
  idxInp.characters = 6;

  win.add('statictext', undefined, decodeURI(f));

  // Buttons
  var btns = win.add('group');
      btns.alignChildren = ['fill', 'center'];

  var cancel = btns.add('button', undefined, 'Cancel', { name: 'cancel' });
      cancel.helpTip = 'Press Esc to Close';

  var ok = btns.add('button', undefined, 'OK', { name: 'ok' });
      ok.helpTip = 'Press Enter to Run';

  cancel.onClick = win.close;

  ok.onClick = function () {
    startIdx = parseInt(idxInp.text);
    if (isNaN(startIdx)) startIdx = 0;

    if (saveRb.value) {
      var abNames = getArtboardNames(doc, startIdx);
      if (abNames.length) writeToText(abNames.join("\n"), f);
    } else {
      var fNames = parseFromText(f);
      if (fNames.length) renameArtboards(doc, fNames, startIdx);
    }
    win.close();
  }

  win.center();
  win.show();
}

main();

function getArtboardNames(doc, idx) {
  if (idx >= doc.artboards.length) return '';
  var abNames = [];
  for (var i = idx; i < doc.artboards.length; i++) {
    abNames.push(doc.artboards[i].name);
  }
  return abNames;
}

function writeToText(str, f) {
  f.open('w');
  f.write(str);
  f.close();
}

function parseFromText(f) {
  f.open('r');
  var contents = f.read();
  var lines = contents.split('\n');
  f.close();
  return lines;
}

function renameArtboards(doc, names, idx) {
  var str = '';
  for (var i = idx; i < doc.artboards.length; i++) {
    str = names[i - idx];
    if (!str) break;
    doc.artboards[i].name = str;
  }
}

 

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 10, 2023 Apr 10, 2023
LATEST

thanks for the update!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines