Copy link to clipboard
Copied
So as you can see I want it to change layer 8 to Pets-simbolos-2
I have tried to write something but it doesn't work, I am new to the scripts.
function test()
{
//var Sel_itemPlaced = app.activeDocument.placedItems[0]; // if nothing is selected - use the first linked file item
var sel_itemPlaced = app.activeDocument.selection[0]; // be sure that a linked item (and not an embedded) is selected
var selPos = sel_itemPlaced.position;
var aTF = app.activeDocument.textFrames.add();
var fileName = sel_itemPlaced.file.name;
var textContents = fileName.replace(/\%20/g," "); //change %20 to spaces
textContents = textContents.replace(/\.[^\.]*$/,""); //remove extension
for (var i = 0; i < layers.length; i++) {
layers.name = textContents;
}
}
test();
I've also tried to find at least one script that allows me to copy the name in the clipboard, at least that will help me a bit, but no luck.
Hi,
Try follwoing snippet. Before you run the script make sure to select the linked file in the document. The following script will rename parent layer of the selected linked item.
function test() {
var sel_itemPlaced = app.activeDocument.selection[0]; // be sure that a linked item (and not an embedded) is selected
var fileName = sel_itemPlaced.file.name;
var textContents = fileName.replace(/\%20/g, " "); //change %20 to spaces
textContents = textContents.replace(/\.[^\.]*$/, "")
...
Copy link to clipboard
Copied
Hi,
Try follwoing snippet. Before you run the script make sure to select the linked file in the document. The following script will rename parent layer of the selected linked item.
function test() {
var sel_itemPlaced = app.activeDocument.selection[0]; // be sure that a linked item (and not an embedded) is selected
var fileName = sel_itemPlaced.file.name;
var textContents = fileName.replace(/\%20/g, " "); //change %20 to spaces
textContents = textContents.replace(/\.[^\.]*$/, ""); //remove extension
var _item = sel_itemPlaced;
while (_item.parent.typename != 'Layer') {
_item = _item.parent;
}
_item.parent.name = textContents;
}
test();
Copy link to clipboard
Copied
It works. Thank you very much.