Computing.Net > Forums > Disk Operating System > Batch file test

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.

Batch file test

Reply to Message Icon

Name: Ducttape19
Date: May 22, 2003 at 08:55:52 Pacific
OS: Win2k
CPU/Ram: enough
Comment:

I am trying to write a batch file that will merge 5 text files into 1. I need a test to see if the files that I am specifying in my copy statement exists. Is there a way to test to see if the files exist and then display an error message if they are not available. Thanks



Sponsored Link
Ads by Google

Response Number 1
Name: beama
Date: May 22, 2003 at 17:43:40 Pacific
Reply:

try this

if not exsist c:\filename.txt goto error

:error
echo File does not exsist



0

Response Number 2
Name: FishMonger
Date: May 24, 2003 at 15:38:06 Pacific
Reply:

Since your testing 5 files, you could do it like this:

echo off
cls

if not exist file1.txt echo File1.txt does not exist

if not exist file2.txt echo File2.txt does not exist

if not exist file3.txt echo File3.txt does not exist

Then prompt the user asking if he wants to continue or exit.

Another option would be to set a variable if a file doesn't exist and based on that var, you'd combine the files or exit without combining.


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: Batch file test

Batch - File Date Test www.computing.net/answers/dos/batch-file-date-test/8385.html

File Size in DOS Batch file www.computing.net/answers/dos/file-size-in-dos-batch-file/3105.html

Batch File: Commands/Prompts www.computing.net/answers/dos/batch-file-commandsprompts/2886.html