Home > InDesign Scripts > Easy way to UnEmbed all Embedded links

Easy way to UnEmbed all Embedded links

Have you ever received document with all links embedded into it? It’s not everyday scene, but it happens, and InDesign has option to unembed link(s) to folder.

But, if you have bunch of links, you need to sort them first, select just embedded ones and then click Unembed Link from Links panel menu, or from context menu. But, it can be done much more easily with help of short script! Let’s see how! 🙂

Link Class has unembed() method which allows us to extract link from InDesign document and save/relink it to new/existing file. Yes, if file doesn’t exist in folder we selected as destination, InDesgn will also create file (extract from INDD file)! That’s really great! The fact is that InDesign stores complete files inside INDD file when you embed it! That means, if you embed PSD file that contains layers, and you unembed it on different computer, you will get original PSD! But, I DON’T suggest you to use this technique to pack all links, especially high-res images inside INDD file! It will just blowup your file! Small logos and graphics are OK, but nothing bigger!

Let’s see how unembed() works:

// first link in document
var myLink = app.activeDocument.links[0];

// check embedded status
$.writeln(myLink.status == LinkStatus.LINK_EMBEDDED);

// unembed to default location

// unembed to new location
// if file exists it will be overwritten with the extracted one
var myDest = Folder("/c/myDestination");

So, here is simple script which will ask you where you want to save all embedded and if some of files already exists in destination folder, they will be automatically relinked instead of overwriting (default unembed() action). Simple and easy!

var myDoc = (app.documents.length && app.activeDocument),
    myLinks = (myDoc) ? myDoc.links : false,
    hasEmbedded = (myLinks && String(app.activeDocument.links.everyItem().status).indexOf("EMBEDDED") != -1) ? true : false;
    myDoc ? undefined : alert("No Documents opened!", "tomaxxiUnEmbed");
    (!hasEmbedded && myDoc) ? alert("No Embedded links found!", "tomaxxiUnEmbed") : undefined;

if(myDoc && myLinks.length != 0 && hasEmbedded){
    var myFolder = Folder.selectDialog("Select folder where Embedded links will be extracted:");
    if(myFolder != null){
        for(var i = 0; i < myLinks.length; i++)
            if(myLinks[i].status == LinkStatus.LINK_EMBEDDED)
                if(File(myFolder + "/" + myLinks[i].name).exists)
                    myLinks[i].relink(File(myFolder + "/" + myLinks[i].name));
        alert("Done!", "tomaxxiUnEmbed");

That’s it!

Have fun! 😀

  1. stacco
    February 28, 2011 at 19:16

    Simple but cute. It’s very helpful script. Thank you.

  2. December 13, 2011 at 16:37

    What about graphics that were copied & pasted and do not show in the Links palette?

  1. February 21, 2011 at 16:47
  2. March 2, 2011 at 20:54

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: