Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

catching error levels for the mkdir command

1,008 views
Skip to first unread message

jaideep

unread,
Apr 14, 2006, 6:48:22 AM4/14/06
to
my batch files is some thing like this

mkdir %input%
.............
....................
......................

following are the lines which use the input lines is there a way that i
can catch the mkdir errorcodes and then exit appropriately

for example

mkdir %input%
if not ERROLEVEL 0 then GOTO ERRORX

something like that ... how to get the error code that the mkdir
returns

any explanations

foxidrive

unread,
Apr 14, 2006, 7:02:21 AM4/14/06
to

What error do you want to catch? A pre-existing folder?

if exist "%input%\" echo folder exists

foxidrive

unread,
Apr 14, 2006, 7:03:50 AM4/14/06
to

that's for NTish windows, BTW.

For Win9x/ME, and not a network drive, use this instead

if exist "%input%\nul" echo folder exists

jaideep

unread,
Apr 14, 2006, 7:15:10 AM4/14/06
to
i want to catch other errors for mkdir like invalid folder name and
other things what are the error codes the command returns....

foxidrive

unread,
Apr 14, 2006, 7:28:14 AM4/14/06
to
On 14 Apr 2006 04:15:10 -0700, jaideep wrote:

> i want to catch other errors for mkdir like invalid folder name and
> other things what are the error codes the command returns....

Work it out emperically.

At a command line in NTish windows enter these:

echo %errorlevel%

md "abc/|def"

echo %errorlevel%

Todd Vargo

unread,
Apr 14, 2006, 8:30:17 AM4/14/06
to

"jaideep" <v.jay...@gmail.com> wrote in message
news:1145011702.1...@e56g2000cwe.googlegroups.com...

Note, it helps to know what OS you are working with. DOS..Win9x/ME do not
return an ERRORLEVEL but NT/XP does. The following code should help.

IF EXIST %input%\nul GOTO skip
MKDIR %input%
IF NOT EXIST %input%\nul GOTO error
:skip

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)


0 new messages