Computing.Net > Forums > Disk Operating System > If exists/errorlevel

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 exists/errorlevel

Reply to Message Icon

Name: MicroD
Date: February 2, 2000 at 08:30:09 Pacific
Comment:

I need a batch file that will check for the existance of a dir on C: and/or D: and then copy into the located dir.
For example:
If Exists c:\test copy \\server\test\*.* c:\test
or
If exists c:\test goto copy
:copy
copy \\server\test\*.* c:\test

If the test directory is on D: I want to copy the files to D:\test
I have also tried to CD into the dir and follow that with an Errorlevel statement.No matter what I try it always copies to root of the drive that doesn't contain the dir and then copies to the correct drive and dir.

HELP!!!!!!



Sponsored Link
Ads by Google

Response Number 1
Name: hellcptr
Date: February 9, 2000 at 01:49:46 Pacific
Reply:

Just insert an file into that directory and let your computer search if this file exists. "IF EXIST" doesn't work with directories. It works only with files.

example
filename: exist.yes

if exist \\server\test\exist.yes goto copy

The problem is that if you search for \\server\test - he tries to find the file "test" on \\server

good luck


0

Response Number 2
Name: SaGS
Date: February 11, 2000 at 06:12:16 Pacific
Reply:

if exist can be used to test for the presence of a directory too, even if that directory is empty.

    if exist directory\nul do_something

(like nul is a "file" that exists everywere.) I think this will beheave strangely with roots of network drives, but is 100% ok for local disks.)

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 exists/errorlevel

If exist any directory? www.computing.net/answers/dos/if-exist-any-directory/1407.html

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

IF EXIST www.computing.net/answers/dos/if-exist/9621.html