Wildcard with IF EXIST doesn't work

Hi,
I want to get a batch file to continue if .txt files exist in the specified directory.
I tried this:

IF EXIST c:\test\*.txt GOTO END
<rest if batch file>
:END

But this ran all the commands without .txt files.

Please could someone tell me how to do this?

Cheers,
tangerine27Asked:
Who is Participating?
 
97WideGlideConnect With a Mentor Commented:
Can you just use brackets instead of goto ?

IF EXIST c:\test\*.txt  ( <rest of batch file> )
0
 
97WideGlideCommented:
UR syntax looks okay to me

what happens if you try?

if exist c:\test\*.txt dir c:\test\*.txt
0
 
Michael PfisterCommented:
IF NOT EXIST c:\test\*.txt GOTO :END
<rest if batch file>
:END
0
 
Michael PfisterCommented:
tangerine27, any news?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.