Solved

NUL

Posted on 2011-03-17
4
693 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 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

Title # Comments Views Activity
find and replace 5 51
old Toshiba laptops supporting both MS Dos and Win 95 22 201
access denied when running native SQL tool: SQLIOSIM 2 59
batch file problem 5 76
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…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

730 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