How do i rename image layers(?) across the whole project using scripts?
Hi
I have a puppet i've made for Character Animator with 5 head views, each one having 2 sets of mouth layers. Within each mouth layer there are different layers for each sound, and inside the layer there is an image layer (not sure if it is considered a layer but i don't know what to call it) and another background layer.
I think I have rigging issues because the image inside the layer has the same name as the layer. Something like this:
Mouth Layer
- Ah
- Ah
- background
It's a bit of a pain to rename them all manually as there are so many so i'm trying to use a script. I am a Javascript developer by trade so it's not a problem but i'm having trouble finding the names of properties to target.
I found a script which works with layers here (link below) but that does the parent layer rather than the image inside.
https://github.com/seblavoie/adobe-illustrator-layer-renamer
I tried modifying it to this but it doesn't work as i'm kind of guessing about what to target:
var LayerRenamer, layerRenamer;
LayerRenamer = (function() {
function LayerRenamer() {
if (app.activeDocument.selection.length > 0) {
this.replacements = [prompt("What would you like to replace?", "Eg: source"), prompt("What would you like to replace it with?", "Eg: replacement")];
this.renameLayers(app.activeDocument.selection);
} else {
alert("Select the layers you would like to be renamed.");
}
}
LayerRenamer.prototype.renameLayers = function(layers) {
var layer, placedItems, placedItem, name, _i, _j, _len, _results;
_results = [];
for (_i = 0, _len = layers.length; _i < _len; _i++) {
layer = layers[_i];
placedItems = layer.placedItems;
placedItem = placedItems[0].placedItem
name = placedItem.name;
_results.push(layer.name = name.replace(this.replacements[0], this.replacements[1]));
}
return _results;
};
return LayerRenamer;
})();
layerRenamer = new LayerRenamer();
