# Input files whose names are dates

I have a lot of files named by date, e.g., 20151118.tex, 20151117.tex, 20151116.tex, etc. These in a directory separated by month and year (2015/11/20151118.tex).

I would like to input these files without having to have to have the following in my main file:

.
.
\input{2015/11/20151117}
\input{2015/11/20151118}


Is there a way to do this with LaTeX. I would like a clean way to do this, if at all possible.

• Generating a file list would be trivial with a combination of (say) ls and sed: ls -R -1 */*/*.tex > filelist.dat, then sed -i 's/^/\\input /' filelist.dat. This lists all .tex files with their paths and prints them to the file filelist.dat; then sed adds \input  to each line. Simply take the list and include it in your main .tex file. You could also "do" that in the actual .tex file if you wanted, but I'm not sure I see the advantage.... – jon Nov 19 '15 at 3:30
• Related question: Iterating over files in a directory and including them. If you know the range of dates that will need to be included this solution should be adaptable to your case. – Peter Grill Nov 19 '15 at 6:23

If you want to incorporate my suggestion above into a single file, this is one approach. The shell commands would need to be different on Windows:

\documentclass{article}

\immediate\write18{ls -R -1 */*/*.tex > filelist.dat}
\immediate\write18{sed -i 's/^/\noexpand\\input /' filelist.dat}%

\immediate\openin\myfile=filelist.dat\relax
\loop

• Thanks, this was what I was looking for. If you are on a Mac, you need to use GNU sed, otherwise the command won't work. – chasely Nov 19 '15 at 14:58