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
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.
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.)
Summary: 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 th...
Summary: Does a command exist that looks to see if a folder exists? As I understand it, the DOS IF EXIST command can only check to see if a file exists. Thanks in advance. ...