Highlighted

Java script to mass embed placed files

New Here ,
Sep 14, 2020

Copy link to clipboard

Copied

Hello everyone!

 

I have quite an odd/massive issue. We have an archive of art, a massive folder of AI file assets. Call it 50,000 items from the past 15-20 years. I am trying to clean up a large amount of space with archiving and deduping data to shrink it down. I have a lot of figuring out thing on my own with this project, but one thing I'll need to do is embed all placed files. I have the locations of the placed where they are supposed to be, I just don't have 10 years of doing all the files individually. Is there a Java Script or some sort of command I can point at 1 base folder, tell it to embedd all the placed files of the AI files in that folder and let it just buck through the list?

 

Please feel free to ask more information

TOPICS
Scripting

Views

147

Likes

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

Java script to mass embed placed files

New Here ,
Sep 14, 2020

Copy link to clipboard

Copied

Hello everyone!

 

I have quite an odd/massive issue. We have an archive of art, a massive folder of AI file assets. Call it 50,000 items from the past 15-20 years. I am trying to clean up a large amount of space with archiving and deduping data to shrink it down. I have a lot of figuring out thing on my own with this project, but one thing I'll need to do is embed all placed files. I have the locations of the placed where they are supposed to be, I just don't have 10 years of doing all the files individually. Is there a Java Script or some sort of command I can point at 1 base folder, tell it to embedd all the placed files of the AI files in that folder and let it just buck through the list?

 

Please feel free to ask more information

TOPICS
Scripting

Views

148

Likes

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
Sep 14, 2020 0
Adobe Community Professional ,
Sep 14, 2020

Copy link to clipboard

Copied

Hello! Luckily you have come to the right place and while the Embed button is non-workable via actions, here in the scripting land there's a very easy code that fortunately fulfills most embedding needs.

 

#target illustrator
function test () {
	var doc = app.activeDocument;
	var thisItem;
	for (var i = 0; i < doc.placedItems.length; i++) {
		thisItem = doc.placedItems[i];
		thisItem.embed();
	}
};
test();

 

In the case of a crazy amount of linked items in the document, there's a chance you may find the script being slow and you may want to try selecting all placed items via same code above, but change newItem.embed() to newItem.selected = true. And then you can click the Embed button to see if that's any faster.
What I noticed is that the .embed() function embeds the images but in my test it only showed a color settings mismatch dialog while clicking the Embed button after selecting all placed images produced an embedding dialog specific to TIFF formats for one of my images which was a Tif.
Some dialogs can be enabled or disabled via script to not show user alerts when a script is running, and others may not be affected by this setting but may have a "don't show again" checkbox so you'd only have to disable them once.

Also, the snippet I provided works on the active document only. It's easily usable against a whole folder by using the Actions' Batch Processing feature to choose a folder and run a script (you have to have it inside the Illustrator's scripts folder so it shows up in File > Scripts menu) which you put into the action via Insert Menu Command and picking the script from File > Scripts.

Likes

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
Reply
Loading...
Sep 14, 2020 0
Adobe Community Professional ,
Sep 14, 2020

Copy link to clipboard

Copied

damn, almost posted at the same time again hahaha

Likes

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
Reply
Loading...
Sep 14, 2020 1
New Here ,
Sep 14, 2020

Copy link to clipboard

Copied

Thank you much for the script :).

 

Yea I need to test it out in a batch and run it in a folder. Basically our company "Archivist" for years was storing files on blu-rays and we are converting them into a sustainable format. So for archiving process I need to do all placed as embedded...for like 30k-50k files. There are only 2-4 placed files in each document. I just don't have the time or sanity to go through the files 1 by 1 for the next year :).

Likes

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
Reply
Loading...
Sep 14, 2020 0
Adobe Community Professional ,
Sep 14, 2020

Copy link to clipboard

Copied

so you have an illustrator file with some placed files in it already?

 

if so, this script will embed them, just open you ai file before running

// embed all placed files
// carlos canto - 09/14/2020

// https://community.adobe.com/t5/illustrator/java-script-to-mass-embed-placed-files/td-p/11432301?page=1

function main() {
    var idoc = app.activeDocument;
    var p = idoc.placedItems;
    
    while(p.length>0) {
        p[0].embed();
    }
}

main();

Likes

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
Reply
Loading...
Sep 14, 2020 1
New Here ,
Sep 14, 2020

Copy link to clipboard

Copied

I do, I have let's say around 30,000-50,000 files. They have roughly 2-3 placed files I need to embed in all of them. I'm more looking for some sort of a batch to just point at a folder with all this stuff and click go and let it run for however long it takes to get it all in.

 

I'll take a peek your script posted 🙂

Likes

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
Reply
Loading...
Sep 14, 2020 0
Adobe Community Professional ,
Sep 14, 2020

Copy link to clipboard

Copied

Silly-V is right that manually embedding placed files is not actionable via the command in the Links palette.

 

But it is possible with an action using the Save As command and turning on the Include Linked Files option. It may also be possible by using the Flatten Transparancy command (Object menu), but that is sometimes a bit "dangerous" for various reasons.

Likes

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
Reply
Loading...
Sep 14, 2020 1
New Here ,
Sep 14, 2020

Copy link to clipboard

Copied

I know, it's not an actionable command. I also have 30k-50k AI files...that all have placed files that I need to embed in a mass batch. I don't really have the option to go through each file and save it one by one.

Likes

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
Reply
Loading...
Sep 14, 2020 0
Adobe Community Professional ,
Sep 14, 2020

Copy link to clipboard

Copied

You wouldn't have to do it manually one by one if you are just using a batch process that includes an appropriate action.

 

Of course, when going this route it is not recommended to process tens of thousands of files at the same time. That may just fail, no matter if you are using the action route or the combined scripting and action route.

Likes

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
Reply
Loading...
Sep 14, 2020 0