Create list of all external files used by master LaTeX document?

The snapshot package gives you a list of the external dependencies of a LaTeX document. Use it by saying

\RequirePackage{snapshot}

before the \documentclass command (to have the information written to a .dep file), or by saying

\RequirePackage[log]{snapshot}

before the \documentclass command (to have the information written to the .log file).


use the perl script mkjobtexmf available with every TeX distribution and run it like

mkjobtexmf --jobname <latex file> --cmd-tex pdflatex 

it creates an file <latex file>.fls which shows all used files, e.g. for a testfile named latex6:

PWD /home/voss/Documents
INPUT /usr/local/texlive/2011/texmf.cnf
INPUT /usr/local/texlive/2011/texmf/web2c/texmf.cnf
INPUT /usr/local/texlive/2011/texmf-var/web2c/pdftex/latex.fmt
INPUT latex6.tex
OUTPUT latex6.log
INPUT /usr/local/texlive/2011/texmf-dist/tex/latex/base/article.cls
INPUT /usr/local/texlive/2011/texmf-dist/tex/latex/base/article.cls
INPUT /usr/local/texlive/2011/texmf-dist/tex/latex/base/size10.clo
INPUT /usr/local/texlive/2011/texmf-dist/tex/latex/base/size10.clo
[ ... ]

This is a modified version of the @Gonzales answer with an additional python code to copy the figures to a new folder.

After using snapshot package to generate the .dep file:

\RequirePackage{snapshot}
\documentclass{article} 

use the following python code (say copy_figs.py) to copy the figures to a separate folder (for example, figs_used):

"""Copy figures used by document."""
import os
import shutil


DEP_FILE = 'main.dep'
TARGET_DIR = 'other_img/'
EXTENSIONS = ['pdf', 'pdf_tex', 'png']


def copy_image_files():
    with open(DEP_FILE, 'r') as f:
        for line in f:
            if '*{file}' not in line:
                continue
            value = line.split('{')[2].split('}')
            source = value[0]
            _, e = os.path.splitext(source)
            e = e.lower()[1:]
            if e not in EXTENSIONS:
                continue
            print(source)
            shutil.copy(source, TARGET_DIR)


if __name__ == '__main__':
    copy_image_files()

To run the python code:

c:\Python27\python.exe copy_figs.py

in the folder where the Latex file is placed. It is assumed the original figures are in figs subfolder, and those figures used in the Latex file are copied to figs_used subfolder. The code copies .png and .pdf figure files.