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

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

Explorer ,
Nov 14, 2022 Nov 14, 2022

Copy link to clipboard

Copied

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

Views

350

Translate

Translate

Report

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(/\.[^\.]*$/, ""); 
...

Votes

Translate

Translate
Adobe
Community Expert ,
Nov 14, 2022 Nov 14, 2022

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

LATEST

Perfect, @Charu Rajput - many thanks!! 🙂 

Votes

Translate

Translate

Report

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