Windows XP Community - XPHeads



Spyware Doctor

mkdir creates file instead of directory ...

microsoft.public.windowsxp.general


Reply
  #1 (permalink)  
Old 07-10-2008, 05:13 PM
Joe HM
 
Posts: n/a
mkdir creates file instead of directory ...
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-10-2008, 07:45 PM
Pegasus \(MVP\)
 
Posts: n/a
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


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-10-2008, 07:59 PM
Joe HM
 
Posts: n/a
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 -


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 07-10-2008, 08:06 PM
Pegasus \(MVP\)
 
Posts: n/a
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.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 07-10-2008, 08:16 PM
Joe HM
 
Posts: n/a
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.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 07-10-2008, 08:44 PM
Pegasus \(MVP\)
 
Posts: n/a
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.



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 02:29 AM.


Registry Mechanic - Free Scan Now
Driver Scanner 2009 - Free Scan Now




Design by Vjacheslav Trushkin for phpBBStyles.com.
Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74