Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
update bcc430e Feb 2, 2018
1 contributor

Users who have contributed to this file

39 lines (35 sloc) 1.07 KB
#target illustratorfunction RenameArtFromText(){ if(app.documents.length > 0 && app.documents[0].selection.length){ function getTextFile(){ var fileType = ($.os.match("Windows"))? "*.txt;*.csv;": function(f){return f instanceof Folder || (f instanceof File && f.displayName.match(/(\.txt|\.csv)$/i));} ; var textFile = File.openDialog("Choose a text file.", fileType); if(textFile != null){ return textFile; } else { alert("Canceled"); return null; } }; var textFile = getTextFile(); if(textFile!=null){ textFile.open('r'); var namesArray = textFile.read().split("\n"); textFile.close(); var doc = app.activeDocument; for(var i = 0; i < namesArray.length; i++){ try{ var thisName = namesArray[i]; var thisItem = doc.selection[i]; thisItem.name = thisName; } catch(e){ // do nothing } } alert("Done with " + i + " names"); } } else { alert("No AI document is open or no selection."); }}RenameArtFromText();
You can’t perform that action at this time.