Skip to content

Instantly share code, notes, and snippets.

@hilukasz
Created May 2, 2012 16:01
Show Gist options
  • Save hilukasz/2577775 to your computer and use it in GitHub Desktop.
Save hilukasz/2577775 to your computer and use it in GitHub Desktop.
function All() {
var doc = app.activeDocument;
// list of items we might want to loop through
var itemsToLoop = [doc.layers, doc.symbolItems];
//reference for method to know how many layers, pathitems, symbols etc are being looped
//can I do: this.itemsToLoop = [doc.layers, doc.symbolItems]; to remove prev var?
this.name = itemsToLoop;
}
All.prototype.findAndReplace = function(find, replace) {
var findTextInSymbolName = prompt("Text to find", find);
var replaceTextInSymbolName = prompt("Text to replace", replace);
for( i = 0; i < this.itemsToLoop[i].length; i++){
for( i = 0; i < this.itemName[i].length; i++){
// find and replace, if no matches then it just continues with no changes,
// built into replace method.
var currentItemName = itemToLoop[i].name;
currentItemName.replace(findTextInSymbolName, replaceTextInSymbolName);
}
}
}
function SymbolName() {
this.name = doc.symbolItems;
}
SymbolName.prototype.findAndReplace = function(find, replace) {
var findTextInSymbolName = prompt("Text to find", this.find);
var replaceTextInSymbolName = prompt("Text to replace", this.replace);
for( i = 0; i < this.itemsToLoop[i].length; i++){
for( i = 0; i < this.itemName[i].length; i++){
// find and replace, if no matches then it just continues with no changes,
// built into replace method.
var currentItemName = itemToLoop[i].name;
currentItemName.replace(findTextInSymbolName, replaceTextInSymbolName);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment