1.

Solve : shortest command to find if a directory exists?

Answer»

I would like to do this so that I can

if exists Dir then echo don't do anything
if not exists dir mkdir c:\thenewdirectory

-----------------------
My current solution is the following.Any SUGGESTION for something shorter?

dir c:\thenewdirectory\ /s >> c:\patches.txt

if exists c:\patches.txt echo don't do anything
if not exists c:\patches.txt mkdir c:\thenewdirectory

This is the shortest solution I can think of based on your example:
Code: [Select]if not exist c:\thenewdirectory md c:\thenewdirectory
But you COULD ALWAYS just use the MD command which will create the directory UNLESS it already exists like this:
Code: [Select]md c:\thenewdirectory>NUL



Discussion

No Comment Found