Computing.Net > Forums > Disk Operating System > if exist statements

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 statements

Reply to Message Icon

Name: Robert L. Miller
Date: December 28, 1998 at 11:06:20 Pacific
Comment:

I am trying to add a line in a batch file which files from a certain directory will be copied if a certain condition exists, but, they do not seem to execute, this is being used on a network, here is the command:
echo Policy Member
echo -------------
echo Updating system, please wait . . .
if exist c:\corel\suite8\ xcopy32 n:\policies\updates c:\ /d /s /e /c /i /q /h /r /k /y > nul:
if exist c:\corel\office7\ xcopy32 n:\updates c:\ /d /s /e /c /i /q /h /r /k /y /u >nul:

if NOT exist c:\windows\system\odma32.dll copy c:\docsopen\progs\odma32.dll c:\windows\system\ > nul
if NOT exist c:\windows\odma.dll xcopy32.exe c:\docsopen\progs\odma.dll c:\windows > nul
Any and all assistance would be greatly appreciated.



Sponsored Link
Ads by Google

Response Number 1
Name: World Library
Date: December 28, 1998 at 16:35:46 Pacific
Reply:

Say! You code like me.......long LOL!

The best way to debug a bat is break it down.
Example:
Note I have made a few test changes as well.
I have also put in a few rems

cls
@echo off
if exist c:\corel\suite8\ goto excop
rem suite8\ ???? (<--suite8\*.*)
goto end
rem If you do not assign a place to go if C:\corel does not exist it will go to the next line of code and exicute it. An if exist
should have ,,,,,by habit a second destination.

What if it does not exist and the next line of code is y|Format C . So give an if exist
a place to go if it does and if it does not
exist. (picky picky picky LOL LOL)

echo if exist c corel being tested.
pause >nul
:excop
echo we are at excop
pause >nul
xcopy32 n:\policies\updates c:\ /d
rem How about xcopy32 c:\policies\updates\*.*
c:\somwhere > nul:


I know putting in "echo we are here or there" is a bummer, but it will help find the errors.

Thought:
if exist C:\corel\ is a incompleate line. if exist C:\corel\stuff.dat is compleate

A open \ with no file or *.* wildcards can bring a bat to a screaming halt.

I hope this is of some help.

But I do like your style of code. Wish some one would help me debug my bats.
I also wish the reply box was a little bigger.


Peace Goodwill and Happy Computing

World Library


0
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 statements

if exist statement www.computing.net/answers/dos/if-exist-statement/13424.html

If exists/errorlevel www.computing.net/answers/dos/if-existserrorlevel/2107.html

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