# 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.

On Linux, something like this will do, without modifying the source:

strace -fe open  make 2>&1  1>/dev/null | grep plots | sed 's/.*\"$$.*$$\".*/\1/' > plots.list

Where :

• make is the command you use to build your output (could be some variation of pdflatex file.tex).

• strace displays the syscalls. With the options we are providing, we keep only the "open" syscalls (-e option) in order to get the figures that are inserted (as well as other opened files foe now). The -f options is to display syscalls of subprocesses and the redirections are to keep only the strace output.

• grep plots selects the lines containing a common string in the path ("plots" in this case).

• sed selects what is inside the quotes.

• The final redirection dumps the result in a file.

You may get duplicate filenames this way, but could be good enough depending what you want.

There is a perl script on CTAN, texdepend that does all of this and more. It handles all sorts of internal and external dependencies, and can generate the information in Makefile, perl or 1-per-line format.

>texdepend
Find LaTex dependencies, Version: 0.96, Michael Friendly (friendly@yorku.ca)
Usage: C:\batchfiles\texdepend.pl <options> texfile[.tex]
where <options> may be abbreviated to unique truncations, and are:
-help               print this measly help
-expand             expand package/include file to full path names
-format = make      print dependencies in Makefile format
perl      print in the form of perl assignments (LatexMk)
1         print one per line (with # separators)
-ignore = list      list of file types to be ignored in .log [default: fd]
-out = filename     send output to filename
-print =            Any one or more of i (includes) p (packages)
f (figs) b (bibfiles) s (styles) d (all dependencies)
-styles = list      list of file types for  from .log [default: sty]
-verbose