Batch scripting for directories or better method
        Posted  
        
            by baron
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by baron
        
        
        
        Published on 2010-04-13T03:41:09Z
        Indexed on 
            2010/04/13
            3:42 UTC
        
        
        Read the original article
        Hit count: 460
        
Hi Everyone,
Looking at creating a simple batch file for my app. My app needs some directories to be in place as it runs.
The first method I thought was just make a batch script:
@ECHO OFF
IF NOT EXIST C:\App GOTO :CREATE ELSE GOTO :DONTCREATE
:CREATE
MKDIR C:\App\Code
ECHO DIRECTORY CREATED
:DONTCREATE
ECHO IT WAS ALREADY THERE
1) This doesn't run as I would expect. Both :CREATE and :DONTCREATE seem to run regardless? How do I do an If properly then?
Output:
A subdirectory or file C:\App\Code already exists.
DIRECTORY CREATED
IT WAS ALREADY THERE
So it enters both true and false statements?
2) The app is a C# WPF app. For what I am trying to do here (create a couple of directories if they don't already exist) - should I do it some other way? Perhaps in the application as it runs?
© Stack Overflow or respective owner