1
@ECHO OFF PAUSE IF EXIST "C:\Program Files\NexphaseV6\ECF" ( ECHO Directory exists! PAUSE ) ELSE ( MKDIR "C:\Program Files\NexphaseV6\ECF" ECHO Directory made! ) PAUSE 

When I run the above batch file I always get the opposite results of what I expect.

So if the directory does exist, it says "Directory Made!", and if it doesn't exist, it says "Directory Exists!"

It's basically the wrong way round - Why is this?

1 Answer 1

1

The batch file looks fine to me and works here (as long as you have directory creation rights in Program Files of course, so you might want to run it from an elevated (admin) command prompt).

One tip is to modify the directory existence test slightly. Instead of:

IF EXIST "C:\Program Files\NexphaseV6\ECF" 

you should use:

IF EXIST "C:\Program Files\NexphaseV6\ECF\" 

Note the trailing backslash. This ensures that if there's a file by that same name then the test won't return True.

1
  • Not too sure how I got it working as I was already running as admin although it works now, thanks! Commented May 6, 2015 at 17:15

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.