<p>I have a file that lists filenames, each on it's own line, and I want to test if each exists in a particular directory. For example, some sample lines of the file might be</p>

<pre><code>mshta.dll
foobar.dll
somethingelse.dll
</code></pre>

<p>The directory I'm interested in is <code>X:\Windows\System32\</code>, so I want to see if the following files exist:</p>

<pre><code>X:\Windows\System32\mshta.dll
X:\Windows\System32\foobar.dll
X:\Windows\System32\somethingelse.dll
</code></pre>

<p>How can I do this using the Windows command prompt? Also (out of curiosity) how would I do this using bash or another Unix shell?</p>

In Windows:
```
```
type file.txt >NUL 2>NUL
if ERRORLEVEL 1 then echo "file doesn't exist"
```
```
(This may not be the best way to do it; it is a way I know of; see also
http://blogs.msdn.com/oldnewthing/archive/2008/09/26/8965755.aspx
)
In Bash:
```
```
if ( test -e file.txt ); then echo "file exists"; fi
```
```