Jump to content

mkdir creates file instead of directory ...


Recommended Posts

Guest Joe HM
Posted

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

  • Replies 5
  • Created
  • Last Reply

Popular Days

Guest Pegasus \(MVP\)
Posted

Re: mkdir creates file instead of directory ...

 

 

"Joe HM" <unixverse@yahoo.com> wrote in message

news:4cc459f1-193c-4818-8bb5-c092ed7dbd5c@b1g2000hsg.googlegroups.com...

> 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

Guest Joe HM
Posted

Re: mkdir creates file instead of directory ...

 

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

 

 

 

On Jul 10, 3:45 pm, "Pegasus \(MVP\)" <I....@fly.com.oz> wrote:

> "Joe HM" <unixve...@yahoo.com> wrote in message

>

> news:4cc459f1-193c-4818-8bb5-c092ed7dbd5c@b1g2000hsg.googlegroups.com...

>

>

>

>

>

> > 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- Hide quoted text -

>

> - Show quoted text -

Guest Pegasus \(MVP\)
Posted

Re: mkdir creates file instead of directory ...

 

 

"Joe HM" <unixverse@yahoo.com> wrote in message

news:777a8c4b-51c9-4110-aa08-1da3df886cbe@a1g2000hsb.googlegroups.com...

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.

Guest Joe HM
Posted

Re: mkdir creates file instead of directory ...

 

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

 

 

 

On Jul 10, 4:06 pm, "Pegasus \(MVP\)" <I....@fly.com.oz> wrote:

> "Joe HM" <unixve...@yahoo.com> wrote in message

>

> news:777a8c4b-51c9-4110-aa08-1da3df886cbe@a1g2000hsb.googlegroups.com...

> 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.

Guest Pegasus \(MVP\)
Posted

Re: mkdir creates file instead of directory ...

 

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 . . .

 

 

"Joe HM" <unixverse@yahoo.com> wrote in message

news:717d7283-7126-42c5-a1c9-f6b7d1ab6ff4@d1g2000hsg.googlegroups.com...

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

 

 

 

On Jul 10, 4:06 pm, "Pegasus \(MVP\)" <I....@fly.com.oz> wrote:

> "Joe HM" <unixve...@yahoo.com> wrote in message

>

> news:777a8c4b-51c9-4110-aa08-1da3df886cbe@a1g2000hsb.googlegroups.com...

> 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.


×
×
  • Create New...