# Find files in subdirectories to use with \input

Is there a way to have TeX find all files ending on .tex in subdirectories of a certain directory to be used as \input?

In my document I would like to include a large number of files from a directory-tree which looks like this:

/transcripts/2013-05/2013-05-12/2013-05-12-transcript1/2013-05-12-transcript1.tex
/2013-05-12-transcript2/2013-05-12-transcript2.tex
/2013-05-14/2013-05-14-transcript1/2013-05-14-transcript1.tex
/2013-06/2013-06-07/2013-06-07-transcript1/2013-06-07-transcript1.tex


I know I can define specific directories with

\makeatletter
\def\input@path{{./transcripts/}{./transcripts/2013-05}}
\makeatother


but it would be nice to be able to tell it something like

./transcripts/*/*/*/


Is there any way how to achieve this?

I know that this question addresses a similar issue. However, I don't want to automatically include the files, they will still be specified by \input{filename}:

\documentclass{article}
\begin{document}

\input{2013-05-12-transcript1.tex}
...
\input{2013-05-12-transcript2.tex}

\end{document}


What I'd like to achieve is to be able to only type the name and not have to type the entire filepath every time.

EDIT: As per the suggestion below I have tried to edit /usr/local/texlive/2015/texmf.cnf by adding TEXINPUTS = /path/to/folder//: so that it would search my folders recursively, but clearly I am missing some basic knowledge about how to do that. Anyone able to help me with this?

EDIT2 (2019): I'm coming back to this question from a while ago:

(a) I haven't been able to get David's answer below to work. Any further help would be appreciated. (b) I would also still like to find a portable solution, to be specified in the preamble of the document itself. Any ideas?

Don't bother with \input@path just set the texmf.cnf or environment variable TEXINPUTS to be

input/transcripts//:


the trailing // means to recursively search subdirectories and the : (or ; on windows) means just prepend this search path to the existing default, so all the standard places are still searched.

• Would you mind expanding on how exactly to change texmf.cnf? I tried to add TEXINPUTS = ~/path/to/input//: to the users texmf.cnf in /usr/local/texlive/2015/ but it still won't find the files. What am I doing wrong? – jan Apr 28 '16 at 9:03
• Sorry, I still couldn't get it to work. Is changing texmf.cnf in /usr/local/texlive/2015/ what you meant? – jan Apr 29 '16 at 4:08
• @jan if you set it in texmf.cnf you need to set the whole thing rather than just .//: as that is where it's set, in the file returned by kpsewhich texmf.cnf or on the command line (with a shell such as bash) you can simply do TEXINPUTS=.//: pdflatex yourfile.tex also kpsexpand '$TEXINPUTS' will show the currently active setting – David Carlisle Apr 29 '16 at 8:28 • Hmm, I still don't seem to get it. kpsewhich texmf.cnf gives me /usr/local/texlive/2015/texmf.cnf as expected. Now I've added TEXINPUTS = /path/to/folder//: to that file. kpsexpand '$TEXINPUTS' gives me exactly that path. But when compiling it still doesn't find it. – jan Apr 29 '16 at 9:06

I've recreated your file structure and this works for me:

transcripts/
├── 2013-05
│   ├── 2013-05-12
│   │   ├── 2013-05-12-transcript1
│   │   │   └── 2013-05-12-transcript1.tex
│   │   └── 2013-05-12-transcript2
│   │       └── 2013-05-12-transcript2.tex
│   └── 2013-05-14
│       └── 2013-05-14-transcript1
│           └── 2013-05-14-transcript1.tex
└── 2013-06
└── 2013-06-07
└── 2013-06-07-transcript1
└── 2013-06-07-transcript1.tex


The file 2013-05-12-transcript1.tex is \textbf{First}, file 2013-05-12-transcript2.tex is \textbf{Second}, file 2013-05-14-transcript1.tex is \textbf{Third}, file 2013-05-14-transcript1.tex is \textbf{Fourth}, and the example file is as follows:

% arara: pdflatex
\documentclass{article}
\begin{document}

\input{2013-05-12-transcript1.tex}
...
\input{2013-05-12-transcript2.tex}
...
\input{2013-05-14-transcript1.tex}
...
\input{2013-06-07-transcript1.tex}

\end{document}


Windows

I've saved it in D:\transcripts

Temporary configuration

Open a command line cmd (you do not need administrator privileges) and execute:

set TEXINPUTS=.;D:/transcripts//;
pdflatex sampleforum.tex


this will work until you close the command line, that is, you must execute this every time after close a command line ... tedious ... yes.

Permanent configuration

Open a command line cmd (you do not need administrator privileges) and execute:

setx TEXINPUTS .;D:/transcripts//;


close command line, open a new and execute:

reg query HKEY_CURRENT_USER\Environment
pdflatex sampleforum.tex


In this way we have configured TEXINPUTSin your environment variable and now it is permeating.

If you need to delete TEXINPUTS from environment variable, use:

reg delete HKEY_CURRENT_USER\Environment /v TEXINPUTS /f


Alternatively this can be done in a graphical mode adjusting your environment variable.

Linux

I've saved it in ~/transcripts

Temporary configuration

export TEXINPUTS=.:~/transcripts//:
pdflatex sampleforum.tex


Permanent configuration

Add in your .bashrc the line:

export TEXINPUTS=.:~/transcripts//:


In both cases (Win/Linux) you do not need admin or root privileges, just a simple user account.

Another option would be to use tlmgr conf auxtrees, but the directory would have in TDS form.

Saludos

just in case someone else wants to replicate ... this line

mkdir -p transcripts/{2013-05/{2013-05-12/{2013-05-12-transcript1,2013-05-12-transcript2},2013-05-14/2013-05-14-transcript1},2013-06/2013-06-07/2013-06-07-transcript1}
`

it makes the job easier :)