# How to get a list of the filenames of the figures embedded in a document

I have a TeX document that is embedding a huge amount of figures from a fig folder that is full of another humongous amount of other figures.

I would like to move the document along with its figures, but I don't want to take the whole fig folder, just the figures in there that are embedded by the document.

Is there a package (or any other way) that allows me to, for example, print out the filenames of all the figures embedded by the document? Something like:

fig/figurename1.eps
fig/figurename2.eps
...
etc


I could then just copy-paste that list and add some cp's in a plain text file and automate the copy of those files to my desired location by running the file in my shell:

$cp fig/figurename1.eps wherever/fig/$ cp fig/figurename2.eps wherever/fig/
...
etc


Of course this is just an idea, if somebody has an alternative to the "file listing and copy-pasting in a shell file" I would be happy to listen =)

$sed '/include/!d' yourfile.tex > outputfile$ sed -i 's/.*{//g' outputfile && sed -i 's/}//g' outputfile


The first sed will delete all lines which do not have the string "include". The second and third sed will leave your output file with the bare filename you had in your .tex file.