Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

NUL

Posted on 2011-03-17
4
Medium Priority
?
710 Views
Last Modified: 2012-05-11
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
0
Comment
Question by:zhshqzyc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 3

Expert Comment

by:OrenRozen
ID: 35156342
0
 
LVL 43

Accepted Solution

by:
Steve Knight earned 200 total points
ID: 35156348
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
 
LVL 43

Expert Comment

by:Steve Knight
ID: 35156354
Didn't notice only 50 points :-(
0
 
LVL 13

Expert Comment

by:Rick
ID: 35156356
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying 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

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

610 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