Skip to content

Instantly share code, notes, and snippets.

@KennyRedman
Created May 19, 2014 19:00
Show Gist options
  • Save KennyRedman/807708b4621980570456 to your computer and use it in GitHub Desktop.
Save KennyRedman/807708b4621980570456 to your computer and use it in GitHub Desktop.
Adobe Illustrator script that reverts layer names according to a CSV file
#target illustrator
csvCodeToName();
function csvCodeToName(){
if(!documents.length) return;
var aFile = File.openDialog( "select your csv file...",'*.csv',false );
aFile.open("r");
var optionFile = aFile.read();
aFile.close();
var options = optionFile.split("\n");
var allLayers = app.activeDocument.layers;
var visibleLayers = [];
for(a=0; a<allLayers.length; a++){
var ilayer = allLayers[a];
if (ilayer.visible) {
visibleLayers.push(ilayer);
}
}
for(b=0; b<visibleLayers.length; b++){
var LayerName = visibleLayers[b].name;
for(c=0; c<options.length; c++){
var optionsplit = options[c].toString().split("|",2);
var optionName = optionsplit[0];
var ehomeNumber = optionsplit[1];
if (ehomeNumber == LayerName){
//alert(optionName);
visibleLayers[b].name = optionName;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment