Computing.Net > Forums > Disk Operating System > If exist any 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.

If exist any directory?

Reply to Message Icon

Name: Jimi Hullegård
Date: October 30, 1999 at 07:45:22 Pacific
Comment:

I´m writing a bat-file. But I have a problem
with the IF-syntax
What should I write if I want to check if there is ANY subdir in a directory?
I know that you type "if exist abc\nul ..." to check if the directory abc exists...

Regards
Jimi



Sponsored Link
Ads by Google

Response Number 1
Name: Ryan Cooley
Date: October 30, 1999 at 20:44:55 Pacific
Reply:

You can't do anything the way you want to, but if you do something similar to what I have below, you can accomplish what you want.

dir/s > ~file.tmp
find filefind exe
if errorlevel 1 goto found

I hope this helped.


0

Response Number 2
Name: Outsider
Date: November 10, 1999 at 11:22:09 Pacific
Reply:

You can do a lot with find.exe, i.e
:: isroot.bat
@ECHO off
CTTY nul
DIR/A/W |FIND.EXE "file(s)"
IF errorlevel=1 ECHO no files on drive >con
IF errorlevel=1 GOTO end
DIR/A/W |FIND.EXE ".." >nul
IF not errorlevel=1 ECHO root directory is not current >con
IF errorlevel=1 ECHO root directory is current >con
:: end

The above will tell you if the root directory
is current. From this you ought to be able
to figure out how to do exactly what you want.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: If exist any directory?

if-exist-dir www.computing.net/answers/dos/ifexistdir/2530.html

IF EXIST & IF NOT EXIST PROBLEMS www.computing.net/answers/dos/if-exist-amp-if-not-exist-problems/8026.html

if exist statements www.computing.net/answers/dos/if-exist-statements/333.html