How to use dynamically generated filenames in \IfFileExists?

by CarpeDiemKopi   Last Updated September 12, 2019 00:23 AM

I have a file 0012in the directory of the following tex file. I want to check the existence or non-existence of files inside the \forloop from 11 to 13.

    \forloop{ct}{11}{\value{ct} < 14} { 
        % \IfFileExists{0012} {
        \IfFileExists{\fileno} {
           fileno: "\fileno{}" exists! \\
        } {       
           fileno: "\fileno{}" doesn't exist! \\

I get this compile error:

! Incomplete \iffalse; all text was ignored after line 15.
<inserted text>

I have no compiler error if I switch to


How can I check the existence of files with my \fileno macro?


fileno: ”0011” exists!
fileno: ”0012” exists!
fileno: ”0013” exists!

I want this output:

fileno: ”0011” doesn't exist!
fileno: ”0012” exists!
fileno: ”0013” doesn't exist!
Tags : macros tex-core

Related Questions

How to define phantoms for depth and height?

Updated June 28, 2015 18:10 PM

Explode arguments in argument list

Updated May 16, 2016 08:09 AM

How is \unexpanded defined?

Updated December 29, 2016 08:09 AM