Test for existence of a folder on a network drive?

R

Rick

How do I test for the existence of a folder on a mapped network drive?
I believe that the test for the NULL device only works on a local drive.
In the XP help it says:

"You cannot use the if command to test directly for a directory, but the
null (NUL) device does exist in every directory. As a result, you can
test for the null device to determine whether a directory exists."

I tried this and it definitely doesn't work on a networked drive. How
do I test then? Thanks.
 
R

Rick

Sorry -- I meant to indicate that I want to perform this test in a
command file. Not sure how to incorporate DIR into a test from a
command file. Is there another way?
 
P

Pegasus \(MVP\)

Rick said:
Sorry -- I meant to indicate that I want to perform this test in a
command file. Not sure how to incorporate DIR into a test from a
command file. Is there another way?

Try this:
@echo off
if exist \\server\share\foldername echo Folder found!
 
R

Rick

Yup, that seems to do it. I read in the Windows Help topic for IF --

"You cannot use the if command to test directly for a directory..."

but it doesn't seem to be true. Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top