I automatically generate slides with foreach:

```
\foreach \n in {1,...,200} {%
  \begin{frame}{Slide with jpeg number \n}
    \includegraphics[height=3cm]{FileA_\n.jpg}
    \includegraphics[height=3cm]{FileB_\n.jpg}
  \end{frame}%
}

```

The .jpg's come from another source, and sometimes a few of them are missing which causes the whole pdf-generation to break: "Package pdftex.def Error.File 'FileB\_17.jpg' not found".

If any of the two .jpg dont exist, I would like that the slide it belongs to will be skipped but that the compilation continues with the rest of the slides. How can I program that in LaTex?

I work in RStudio with knitr.