Computing.Net > Forums > Disk Operating System > Need help with a Dos batch file

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.

Need help with a Dos batch file

Reply to Message Icon

Name: Neil Bhandar
Date: April 10, 2003 at 06:47:01 Pacific
OS: Win XP
CPU/Ram: Pentium III/1GB
Comment:

Hello:

Need help with a DOS batch file. I am trying to write a very simple batch process, that checks if a DIR by the name MyFiles exists if it does not just creates it.

Question is:
How do I verify this condition using IF statement?
Are there other alternatives to the IF statement if so what?

here is the script.

----------------
REM Check to see if C:\MyFiles dir exists
if exists c:\MyFiles goto DirExists

:DirExists
cd c:\MyFiles
echo The dir C:\MyFiles exists >> Installation.log
----------------

Your help is appreciated. Thanks in advance.
-Neil



Sponsored Link
Ads by Google

Response Number 1
Name: IVO
Date: April 10, 2003 at 07:05:33 Pacific
Reply:

Use the following If:

If exist C:\MyFiles\Nul GoTo DirExist
Echo The Dir C:\MyFiles does not exist
Echo The Directory is being created
MD C:\MyFiles

In each directory you can test for the presence of the "Nul" file changing the test for existence of file in a test for existence of Directory.


0

Response Number 2
Name: Neil Bhandar
Date: April 10, 2003 at 07:34:29 Pacific
Reply:

Thanks a lot IVO!!

When I tried the suggestion it gave me the following error.

c:\MyFiles\Nul was unexpected at this time.

Any other suggestions I could try?
-Neil


0

Response Number 3
Name: IVO
Date: April 10, 2003 at 07:55:22 Pacific
Reply:

The message you get sounds like a bad If compiled... I suppose it is due to the REM line, but for a better diagnosis I need you post your script as it is.
To the next post


0

Response Number 4
Name: Neil Bhandar
Date: April 10, 2003 at 08:15:33 Pacific
Reply:

Your were absolutely right!!

I messed up the IF statement...
used EXISTS instead of the EXISTS

it works now!

Appreciate your help,
-Neil


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: Need help with a Dos batch file

Warm Boot Windows NT with a DOS batch file www.computing.net/answers/dos/warm-boot-windows-nt-with-a-dos-batch-file/5118.html

archive in dos batch file www.computing.net/answers/dos/archive-in-dos-batch-file/12924.html

Need help in a dos batch file www.computing.net/answers/dos/need-help-in-a-dos-batch-file/12379.html