Copy link to clipboard
Copied
Hi, guys.
How can i delete all instance of a linked object.
We have these options when we select a linked object in link panel. but what if i need to delete all instance of a linked object?
thank you.
Copy link to clipboard
Copied
You cannot - you'd need to go to each image placed and delete it manually.
It might be possible with a script or another method that I'm not aware of .
Copy link to clipboard
Copied
Hi there,
Thanks for reaching out. As @Eugene Tyson said, it is not possible in InDesign as of now. I would suggest you post it here (https://indesign.uservoice.com/). This way, you will keep getting all the updates related to this feature, and other users can also upvote, which would help us prioritize. Also, this is the best way of communicating with the Engineering and Product teams regarding issues and suggestions so they can be implemented in future releases.
Regards,
Anshul Saini
Copy link to clipboard
Copied
This is actually a useful idea for the Links panel! I like it.
Copy link to clipboard
Copied
You can do this by the 'Remove all instances of the same link' script.
Copy link to clipboard
Copied
Hi Kasyan,
I was just looking at that script! I wish it could become a Links panel menu choice, perhaps by way of a startup script. I was trying to get ChatGPT to rewrite the script to function that way in the Links panel, but ChatGPT is pretty lame when it comes to writing ExtendScripts.
Copy link to clipboard
Copied
Hi Mike,
It's possible to do — make a script acting as a menu item — but I'm too busy with my daily work to get down to this at the moment.
— Kasyan
Copy link to clipboard
Copied
I can make it a button and it works - stays active on the document -
I don't know how to make it a an addition in the sub menu panels
Run the script and get a floating button - not hte nicest but I gave it a go
#targetengine "session"
var myWindow = new Window("palette", "Link Tools", undefined);
myWindow.orientation = "row";
// Add a button
var removeButton = myWindow.add("button", undefined, "Remove All Instances");
removeButton.onClick = function () {
removeAllInstances();
};
myWindow.show();
function removeAllInstances() {
if (app.documents.length == 0) {
alert("No documents are open. Please open a document and try again.");
return;
}
var doc = app.activeDocument;
var links = doc.links;
if (app.selection.length != 1 || app.selection[0].graphics.length != 1) {
alert("Select a graphic frame with an image.");
return;
}
var selectedLink = app.selection[0].graphics[0].itemLink;
if (!selectedLink) {
alert("Selected item doesn't contain a link.");
return;
}
var filePath = selectedLink.filePath;
var removedCount = 0;
for (var i = links.length - 1; i >= 0; i--) {
if (links[i].filePath == filePath) {
try {
var frame = links[i].parent.parent;
frame.remove();
removedCount++;
} catch (e) {
$.writeln(e);
}
}
}
alert(removedCount + " links have been removed.");
}
Copy link to clipboard
Copied
Currently, I'm not sure if it's possible to add a menu item to a panel, but I know it's possible in the main and context menu.
For example, assumingly the 'Remove all instances of the same link' script installed in the app's scripts panel folder, the following script (to be installed in the startup scripts folder) would create the Scripts > Remove all instances of the link menu like this:
#targetengine "kasyan"
var myScript1 = new File(app.filePath + "/Scripts/Scripts Panel/Remove all instances of the same link 1.0.jsx");
var myScriptAction1 = app.scriptMenuActions.add("Remove all instances of the link");
var myEventListener1 = myScriptAction1.eventListeners.add("onInvoke", myScript1, false);
try{
var myScriptMenu = app.menus.item("$ID/Main").submenus.item("Scripts");
myScriptMenu.title;
}
catch (myError){
var myScriptMenu = app.menus.item("$ID/Main").submenus.add("Scripts");
}
var myScriptMenuItem1 = myScriptMenu.menuItems.add(myScriptAction1);
Of course, more menu items pointing to other scripts can be added using the first one as an example.
— Kasyan
Copy link to clipboard
Copied
Here's the code (a start up script) that creates a menu item in the Links panel to trigger the script located in the app's scripts panel folder:
#targetengine "kasyan"
var myScript1 = new File(app.filePath + "/Scripts/Scripts Panel/Remove all instances of the same link 1.0.jsx");
var myScriptAction1 = app.scriptMenuActions.add("Remove all instances of the link");
var myEventListener1 = myScriptAction1.eventListeners.add("onInvoke", myScript1, false);
try{
var myScriptMenu = app.menus.item("Links Panel Menu");
myScriptMenu.title;
if (myScriptMenu.isValid && myScript1.exists) {
var myScriptMenuItem1 = myScriptMenu.menuItems.add(myScriptAction1);
}
}
catch (myError){}
There's more space for improvement but that's where I've got so far.
P.S. This version works only in English locale.
Copy link to clipboard
Copied
Super interesting and thanks for your replies.
Kasyan, the first script worked for me but the second one did not.
I like the basic idea, though!
Copy link to clipboard
Copied
Here I updated my script. Now, it's a single script that should be installed in the start-up folder.
It should work in non-English versions (locales) of InDesign. I tested it in version 2024/5 on Mac & Windows and it works for me.
Copy link to clipboard
Copied
Hi Kasyan,
Thanks for this script. It is a completely satisfying addition to the Links panel!
Also, it works fine when installed in the User versus the Application.
It undoes in one step--always a nice touch. I give it two thumbs way up!
This will definitely go in my "Anytime Upgrades" startup scripts recommendations.