Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I thought a while back (DOS 5 or 6) I wrote a batch file that used "if exist" to check to see if a directory contains no files. But now using an X/P DOS prompt I can't make anything work. I've tried the following and many others:
if exist c:\temp goto s1
if exist c:\temp\*.* goto s1
if exist c:\temp\nul goto s1These all go to s1 if c:\temp exists, it doesn't matter if c:\temp is empty or contains files. Have things changed since DOS 5? If so, how could I check for an empty directory? I don't want to depend on an external command.

http://www.pcmag.com/article2/0,175...
Just be careful not to delete any empty folders created by Windows itself.
i_Xp/VistaUser

DOS is history.
There is no relationship between DOS and XP.
XP does not function by way of DOS.
So the commands in the Command Prompt are limited.

Commands at the XP command prompt are limited? That is a very false statement. But I do think what I am asking is impossible and I have already moved on to another plan. Thanks for the responses.

No it is NOT a very false statement. Chuck is correct. You need to understand that Windows XP loads without any regard to DOS whereas Windows 98 loads only after DOS. Hence the term "So the commands in the Command Prompt are limited" in Windows XP.
i_Xp/VistaUser

I just wanted to say I found my old batch file and the way I did it back then is pretty simple. Since RD will only delete an empty directory I did a "rd c:\temp" first and go from there. I just have to make sure permissions are set to allow deleting of that directory.
I also have another observation – “Windows XP loads without any regard to DOS whereas Windows 98 loads only after DOS” is a very absurd statement. What difference does that make? Who even cares which loads first? The fact is almost all batch files written in DOS 6.22 will work in a XP Prompt and a lot of DOS commands have been improved since 6.22.

![]() |
Unexpected shut down
|
CD-Ram recording question
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |