# Automatically copying over files required to compile a tex file

I want a command which takes as input, a tex file, and a list of directories. It should (recursively) identify any files the tex file depends on (`\include` or `\includegraphics`) and copy them into the current directory.

The advantage of this is the ability to reuse and modify material from old papers and talks to new ones (without destroying the old ones).

Typical scenario: I want to give a talk which introduces the same material as a previous talk. I copy the beamer presentation from the previous talk and strip out the irrelevant stuff. Now I manually copy over the images I want to keep. I then modify some of those images and create the rest of the presentation...

• for the graphics, you could keep them all in a master directory, and just tell the `graphicx` package the path at the beginning of each document. for the `tex` files, this sounds like a scripting job, either with `perl` or `bash` – cmhughes Mar 8 '12 at 19:12
Try `latexmk`, it has a `-dependents` (or `-deps-out=`) option that lists (or writes to a file) the files required for compiling the document. Together with some scripting, this can be used to strip all unnecessary files.