Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Script to rename <Linked File> in layer with image filename?

Explorer ,
Nov 14, 2022 Nov 14, 2022

I am looking for a script that will rename the layer name <Linked File> with the placed linked filename, please? All at once would be great!

 

I tried this, but doesn't achieve what I'm after.

 

Any help is greatly appreciated.  

Thanks!

TOPICS
Scripting
596
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Nov 14, 2022 Nov 14, 2022

Hi @Phil5C41 ,

Try below version of the script that you have suggested.

function main() {
    var _linkedItems = app.activeDocument.placedItems;
    for (var l = 0; l < _linkedItems.length; l++) {
        var sel_itemPlaced = _linkedItems[l]; // 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(/\.[^\.]*$/, ""); 
...
Translate
Adobe
Community Expert ,
Nov 14, 2022 Nov 14, 2022

Hi @Phil5C41 ,

Try below version of the script that you have suggested.

function main() {
    var _linkedItems = app.activeDocument.placedItems;
    for (var l = 0; l < _linkedItems.length; l++) {
        var sel_itemPlaced = _linkedItems[l]; // 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
        sel_itemPlaced.name = textContents;
    }
}
main();
Best regards
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 14, 2022 Nov 14, 2022
LATEST

Perfect, @Charu Rajput - many thanks!! 🙂 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines