• 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 select links only in the panel

Explorer ,
Apr 10, 2024 Apr 10, 2024

Copy link to clipboard

Copied

Hey guys.
I need help selecting links in the panel. Is there any script (or can someone help me create it) so that I can select the links in my document only in the links panel? And I also need the script to select only links that have a piece of the indd file name in their name.
Ex:
My indesign file has the name: "teste_name.indd"
My links have names:
test_name_img1.jpg
test_name_img2.jpg
test_name_img3.jpg
img_10
img_11

Then, the script will select only the links in the panel ((because these files (in the panel) are the ones whose name is the same as the file name.))
can anybody help me? 
I could only think of this, but it doesn't work:

var doc = app.activeDocument;
for (var d = doc.links.length-1; d >= 0; d--) {
     var link = doc.links[d];
     app.select(link);

     }


can anybody help me? I would need this script to add to another larger one that I am creating.
Exemple in image.

TOPICS
Feature request , How to , Scripting

Views

342

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
Community Expert ,
Apr 10, 2024 Apr 10, 2024

Copy link to clipboard

Copied

What do you want to do with the link after you select it? Do you want to manipulate its parent frame, or something else? You can't select across multiple spreads, so just selecting, even as an ADD TO SELECTION would not work. To test the name of the indd doc against the link name, you could try the following: 

var doc = app.activeDocument;
var nm = new RegExp(doc.name.replace(/\.indd$/i,""),"i");
for (var d = doc.links.length-1; d >= 0; d--) {
     var link = doc.links[d];
     if (nm.test(link.name) { 
        //do something with link. link.parent would get its frame
     }
}

 

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 ,
Apr 12, 2024 Apr 12, 2024

Copy link to clipboard

Copied

these links will be relinked to another local folder. It's just a way to automate, as the other links that I didn't select will be relinked by other files.

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
Community Expert ,
Apr 12, 2024 Apr 12, 2024

Copy link to clipboard

Copied

If you want to relink to another folder, then use my snippet above and in the comment block, try something like:

 

link.relink(File(someFolder +"/" + link.name);

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
Community Expert ,
Apr 12, 2024 Apr 12, 2024

Copy link to clipboard

Copied

LATEST
quote

 It's just a way to automate, as the other links that I didn't select will be relinked by other files.


By @eusoujpg

 

you'll need to "select" the desired links in your script because, as it was mentioned, there's no way to select specific links in the Links panel via scripts. that is, your script will need to obtain the list of document links, filter it according to your requirements for the link names, then act upon the found links (relink them or anything else you need to do).

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
Community Expert ,
Apr 10, 2024 Apr 10, 2024

Copy link to clipboard

Copied

Hi @eusoujpg , If by select you mean you want to select the items in the Link panel’s list (not select the linked assets on the pages), that can’t be done via scripting

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
Community Expert ,
Apr 10, 2024 Apr 10, 2024

Copy link to clipboard

Copied

As already mentioned script rarely has any capability like selecting objects to do anything on the native panels. So you will need to let us know what you want to do after selecting the items we could explore the possibility of acheiving that.

-Manan

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 ,
Apr 11, 2024 Apr 11, 2024

Copy link to clipboard

Copied

Well, always is the way...

I am not scripter but..... scripters can use this approach: 

Select your links in link's panel, then script will generate captions, and will group captions with links (Frame on page). Then script will search links name in this captions frame and delete whole group. So I bet, this is possible 🙂 

Convince me it's not possible 🙂

Yt/DtptutorialyCZ

 

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
Community Expert ,
Apr 11, 2024 Apr 11, 2024

Copy link to clipboard

Copied

Select your links in link's panel,

 

There's no method in the scripting API that will get the panel's selected links. If there are linked objects on a spread that have been selected, then yes.

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 ,
Apr 11, 2024 Apr 11, 2024

Copy link to clipboard

Copied

ok, "i made" this script:
https://youtu.be/2BUeYBS8NQY
with this guy
https://www.corullon.com.br/scripts/
So contact him for more info 🙂




 

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
Community Expert ,
Apr 12, 2024 Apr 12, 2024

Copy link to clipboard

Copied

The script is removing links from the document, which I don’t think is what @eusoujpg is asking for.. The request is to script the selection of a range of items in the Links panel’s list (which might be on different spreads):

 

Before running:

 

Screen Shot 20.png

 

After:

 

Screen Shot 21.png

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 ,
Apr 12, 2024 Apr 12, 2024

Copy link to clipboard

Copied

Yes, that's it! these links will be relinked to another local folder. It's just a way to automate, as the other links that I didn't select will be relinked by other files.aS

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
Community Expert ,
Apr 12, 2024 Apr 12, 2024

Copy link to clipboard

Copied

@DTPtutorialyCZ-L.Zalesky 

 

Can you confirm which script it is exactly?

 

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
Community Expert ,
Apr 12, 2024 Apr 12, 2024

Copy link to clipboard

Copied

@DTPtutorialyCZ-L.Zalesky 

 

OK. I know how it is done - After Link is selected - Invoke can be used.

 

RobertTkaczyk_1-1712923890237.png

 

RobertTkaczyk_2-1712923904128.png

 

If only one link is selected:

RobertTkaczyk_0-1712924090278.png

 

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
Community Expert ,
Apr 12, 2024 Apr 12, 2024

Copy link to clipboard

Copied

After Link is selected - Invoke can be used.

 

Maybe @eusoujpg  can confirm, but I don’t think there is a selection in the Links panel before the run—the script needs to make the selection of a range of items.

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
Community Expert ,
Apr 12, 2024 Apr 12, 2024

Copy link to clipboard

Copied

quote

After Link is selected - Invoke can be used.

 

Maybe @eusoujpg  can confirm, but I don’t think there is a selection in the Links panel—the script needs to make the selection of a range of items.


By @rob day

 

If you select few items on the list - this will return list of selected links:

Copy Info for Selected Links Copy Info for Selected Links Panel Menus:Links

132619

 

RobertTkaczyk_0-1712926125461.png

 

 

But there is a problem - it will return just the name of the file - with path if you enable it in options.

 

Solution with generating Captions is correct - will create captions for ONLY selected instances:

 

RobertTkaczyk_2-1712926463829.png

 

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
Community Expert ,
Apr 12, 2024 Apr 12, 2024

Copy link to clipboard

Copied

If you select few items on the list - this will return list of selected links

 

But there is no selection @eusoujpg wants to script a the selection

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
Community Expert ,
Apr 12, 2024 Apr 12, 2024

Copy link to clipboard

Copied

quote

Select your links in link's panel, then script will generate captions, and will group captions with links (Frame on page). Then script will search links name in this captions frame and delete whole group. So I bet, this is possible 🙂 

Convince me it's not possible 🙂


By @DTPtutorialyCZ-L.Zalesky

 

Instead of generating captions - and doing extra processing - Invoke from the Copy Info can be used:

Copy All Link Information Copy All Link Information Panel Menus:Links 132618
Copy Full Path Copy Full Path Panel Menus:Links 132623
Copy Info Field Copy Info Field Panel Menus:Links 132649
Copy Info for Selected Links Copy Info for Selected Links Panel Menus:Links 132619

 

 

You are right - the idea with generating Captions is much better.

 

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