mkdir creates file instead of directory ...

J

Joe HM

Hello -

I have this strange intermittent problem where a mkdir command in a
batch file will create a file with the name of a directory instead of
the directory itself. This has happened for several people and I have
no clue what is causing it.

Here is the code ...

if not exist "C:\Program Files\X" mkdir "C:\Program Files\X"
if not %ERRORLEVEL% == 0 goto error
if not exist "C:\Program Files\X\Y" mkdir "C:\Program Files\X\Y"
if not %ERRORLEVEL% == 0 goto error

Could this be because I am creating two directories or is this a bug
with mkdir?

I/we have XP SP2.

Thanks,
Joe
 
P

Pegasus \(MVP\)

Joe HM said:
Hello -

I have this strange intermittent problem where a mkdir command in a
batch file will create a file with the name of a directory instead of
the directory itself. This has happened for several people and I have
no clue what is causing it.

Here is the code ...

if not exist "C:\Program Files\X" mkdir "C:\Program Files\X"
if not %ERRORLEVEL% == 0 goto error
if not exist "C:\Program Files\X\Y" mkdir "C:\Program Files\X\Y"
if not %ERRORLEVEL% == 0 goto error

Could this be because I am creating two directories or is this a bug
with mkdir?

I/we have XP SP2.

Thanks,
Joe

The probability of there being a bug with mkdir is extremely small.
It is far more likely that you created a file called "mkdir.bat", which
is not a good idea. What happens if you replace the command
"mkdir" with its alias "md"?

By the way, you could tighten your code like so:
if not exist "C:\Program Files\X" md "C:\Program Files\X" || goto error
if not exist "C:\Program Files\X\Y" md "C:\Program Files\X\Y" || goto error
 
J

Joe HM

Hello -

The batch file is called INSTALL.XXX.bat and not mkdir.bat.

I will try the md ... what is the difference? Is the || always
equivalent to if not %errorlevel% == 0?

Thanks a lot!
Joe
 
P

Pegasus \(MVP\)

Hello -

The batch file is called INSTALL.XXX.bat and not mkdir.bat.

I will try the md ... what is the difference? Is the || always
equivalent to if not %errorlevel% == 0?

Thanks a lot!
Joe

====================

I did not say that your batch file is called mkdir.bat. I suggested that
you have a file mkdir.bat (or mkdir.cmd) hanging about, perhaps from
a previous exercise.

The || connector executes the command following it if the preceding
command returns an error level > 0. Its twin brother is the && connector.
 
J

Joe HM

Hello -

I see ... I searched my machine and found a mkdir.exe in C:\cygwin
\bin. I think this is somewhere at the end of my path so it should
not be executed. I have actually not seen the problem on my own
machine but on other people's machines. They do not have Cygwin
installed ... why would the mkdir.exe help???

What is the && doing? I assume it is not an "and" since I have
unsuccessfully tried to find such a thing ...

Thanks!
Joe
 
P

Pegasus \(MVP\)

You need to search the other machines for mkdir.*

A quick test would show you that the || connector detects
ErrorLevel > 0 whereas its twin && detects ErrorLevel = 0 . . .


Hello -

I see ... I searched my machine and found a mkdir.exe in C:\cygwin
\bin. I think this is somewhere at the end of my path so it should
not be executed. I have actually not seen the problem on my own
machine but on other people's machines. They do not have Cygwin
installed ... why would the mkdir.exe help???

What is the && doing? I assume it is not an "and" since I have
unsuccessfully tried to find such a thing ...

Thanks!
Joe
 
P

Pegasus [MVP]

in message
good morning ,

i have a greatest doubt..... can u tell me where this
mkdir.exe will be located in a computer.. surely it will be in DRIVE 'C'
only... may i know the location of that.. i have searched completely ,
but i couldn't find it....

pl. help me out...


thank u in adavce

S.R.Vignesh

mkdir (or its synonym "md") belongs to the class of commands such as copy,
cd, rd or del that are internal to the Command Processor cmd.exe.
 
P

Pegasus [MVP]

in message
oh fine :) so , internal commands can't be found inside our system?????
:)

They exist as commands but the do not have files associated with them.
 
B

B&E

undisclosed said:
good morning ,

i have a greatest doubt..... can u tell me where this
mkdir.exe will be located in a computer.. surely it will be in DRIVE 'C'
only... may i know the location of that.. i have searched completely ,
but i couldn't find it....

pl. help me out...


thank u in adavce

S.R.Vignesh
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top