Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Wildcard with IF EXIST doesn't work

Posted on 2008-11-13
4
Medium Priority
?
2,397 Views
Last Modified: 2012-05-05
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,
0
Comment
Question by:tangerine27
  • 2
  • 2
4 Comments
 
LVL 8

Accepted Solution

by:
97WideGlide earned 2000 total points
ID: 22949797
Can you just use brackets instead of goto ?

IF EXIST c:\test\*.txt  ( <rest of batch file> )
0
 
LVL 8

Expert Comment

by:97WideGlide
ID: 22949833
UR syntax looks okay to me

what happens if you try?

if exist c:\test\*.txt dir c:\test\*.txt
0
 
LVL 29

Expert Comment

by:Michael Pfister
ID: 22950046
IF NOT EXIST c:\test\*.txt GOTO :END
<rest if batch file>
:END
0
 
LVL 29

Expert Comment

by:Michael Pfister
ID: 22974120
tangerine27, any news?
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question