Computing.Net > Forums > Windows XP > Checking for an empty directory

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Checking for an empty directory

Reply to Message Icon

Name: worky
Date: December 4, 2007 at 21:54:10 Pacific
OS: X/P SP 2
CPU/Ram: P4
Comment:

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 s1

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



Sponsored Link
Ads by Google

Response Number 1
Name: XpUser
Date: December 4, 2007 at 22:05:08 Pacific
Reply:

http://www.pcmag.com/article2/0,175...

Just be careful not to delete any empty folders created by Windows itself.

i_Xp/VistaUser


0

Response Number 2
Name: worky
Date: December 4, 2007 at 22:08:49 Pacific
Reply:

Sorry, SORT is an external command.


0

Response Number 3
Name: Chuck 2
Date: December 5, 2007 at 08:12:08 Pacific
Reply:

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.


0

Response Number 4
Name: worky
Date: December 5, 2007 at 12:59:53 Pacific
Reply:

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.


0

Response Number 5
Name: XpUser
Date: December 5, 2007 at 13:37:02 Pacific
Reply:

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


0

Related Posts

See More



Response Number 6
Name: worky
Date: December 14, 2007 at 14:24:44 Pacific
Reply:

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.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Unexpected shut down CD-Ram recording question



Post Locked

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


Go to Windows XP Forum Home


Sponsored links

Ads by Google


Results for: Checking for an empty directory

BAT File conditional check for empty string www.computing.net/answers/windows-xp/bat-file-conditional-check-for-empty-string/175698.html

question about viruses,& Documents www.computing.net/answers/windows-xp/question-about-virusesamp-documents/105567.html

run32.dll missing when switch user www.computing.net/answers/windows-xp/run32dll-missing-when-switch-user/105533.html