NUL

Hi, can you please explain to me what is "NUL"? Google it but no luck.
set p=%1

if not exist %p%\nul mkdir %p%

Open in new window

Thanks
zhshqzycAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Steve KnightConnect With a Mentor IT ConsultancyCommented:
Well NUL is a device that eats any input sent to it, e.g.

dir > NUL

results in no output unless there are errors,

dir > NUL 2>&1

says to send standard output to NUL and any errors (2>) to same place.

As a file check like this "NUL" exists everywhere so they have used it to check if a directory exists.  

if exist %p% mkdir %p%

then it would also check if a file of the same name existed for instance.

You could just do:

mkdir  "%~1" >NUL 2>&1

The ~ removes the quotes if existing so they can be re-added to make sure they are there for a path with spaces in.

Steve
0
 
OrenRozenCommented:
0
 
Steve KnightIT ConsultancyCommented:
Didn't notice only 50 points :-(
0
All Courses

From novice to tech pro — start learning today.