Solved

NUL

Posted on 2011-03-17
4
671 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

863 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now