I am trying to write a template to automatically load files inside directories formatted in a certain way, and I want to print something every time a new file is found in a directory previously empty.
My code looks like this:
\documentclass[11pt,twoside,a4paper]{article}
\usepackage{tikz}
\usepackage{etoolbox}
\usepackage[utf8]{inputenc}
\begin{document}
\foreach \Year in {2016,...,2020}
{
\newtoggle{mytoggle}
\toggletrue{mytoggle}
\foreach \Month in {Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec}
{ \foreach \Day in {1,...,31}
{ \IfFileExists{\Year/\Month/\Day}
{
\iftoggle{mytoggle}{
\togglefalse{mytoggle}
true
}{
false
}
\input{\Year/\Month/\Day.tex}
}
}
}
}
\end{document}
I would expect that the true branch is called only once, however it is called every time. What am I doing wrong?
Thanks


\newtogglein the loop over and over again looks weird – Mar 24 '16 at 08:25\InputIfFileExistsas well, this combines the test for the existince of the file and the input – Mar 24 '16 at 08:29