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
Solved

NUL

Posted on 2011-03-17
4
685 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
  • 2
4 Comments
 
LVL 3

Expert Comment

by:OrenRozen
ID: 35156342
0
 
LVL 43

Accepted Solution

by:
Steve Knight earned 50 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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone 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

Suggested Solutions

One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_2459…
Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

828 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