Tips From The Blog XIV: embedded file locations in an Adobe Illustrator file

I was working on a figure in Adobe Illustrator today. The ai file had 32 embedded TIFF files (we tend to embed images rather than linking them for portability reasons).

I wanted to change all of the images, but to do this I needed to know where the originals were. Clicking on the file shows the original filename in the top left of the main window, and hovering over the name reveals the path to the original file (even if you have no access to it). So the info is in the ai file, even though the file is embedded. How can we get it out?

A quick search revealed no obvious way to get a list of the original locations of all embedded files, so I dropped the file into Atom to have a look at it.

Well, it turns out ai files are human readable. That means they’re grep-able.

grep -i "stRef:filePath"

This reveals a list of embedded files enclosed in tags. They are in the layer order too which is quite handy!

This output can be saved as a text file like so:

grep -i "stRef:filePath" > ~/Desktop/files.txt

With a quick bit of find-and-replace I could replace the outputs like this


Into this

cp '/path/to/embedded/file1.tif' ~/Desktop/ ;\
cp '/path/to/embedded/file2.tif' ~/Desktop/

…and voila, the embedded files are copied to my desktop.

Yes, I know that if we don’t embed images, they can be modified in their original location, and the ai file is updated. But that’s not how we work.

This post is part of a series of tips.