Created
May 19, 2014 18:59
-
-
Save KennyRedman/8a01aa829c072bdfeafe to your computer and use it in GitHub Desktop.
Adobe Illustrator script that renames layers according to a CSV file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#target illustrator | |
csvNameToCode(); | |
function csvNameToCode(){ | |
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 (optionName == LayerName){ | |
//LayerName = ehomeNumber; | |
visibleLayers[b].name = ehomeNumber; | |
} | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment