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
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
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
Summary: I am trying to create a DOS batch file that will shut down my Windows NT 4.0 workstation. I know there are Windows based schedulers that will do this, but I need a MS-DOS batch file...
Summary: Hello, I need help creating a dos batch file that will move files in many directories from one server to another if they are older than 30 days. Thanks ...
Summary: Hi all, Thanks a Lot for your response!! I found that the terminal services client stops the processing of the batch file when using both Call command as well as using the %comspec% /c filename.exe m...