Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

Subject: read a file from a batch file???

Original Message
Name: pqsi
Date: May 7, 2008 at 10:53:34 Pacific
Subject: read a file from a batch file???
OS: xp pro
CPU/Ram: core 2
Model/Manufacturer: dell
Comment:
I am trying to create a batch file to read a text file that will only contain either a 1 or a 0 and report it back.

Do I use the find command or???

Thank you in advance.


Report Offensive Message For Removal

Response Number 1
Name: DosX
Date: May 7, 2008 at 13:03:10 Pacific
Subject: read a file from a batch file???
Reply: (edit)
-- test.txt --
0

-- read.bat --
@ECHO OFF
FIND "1" test.txt
IF ERRORLEVEL 1 GOTO zero
IF ERRORLEVEL 0 GOTO one

:error
ECHO There was some error.
GOTO exit

:one
REM we found 1 in a file
ECHO Test.txt contains 1
GOTO exit

:zero
REM File does not contain 1, but it doesn't
REM mean it contains 0
FIND "0" test.txt
IF ERRORLEVEL 1 GOTO error
IF ERRORLEVEL 0 GOTO realzero
GOTO error

:realzero
ECHO Test.txt contains 0

:exit


Report Offensive Follow Up For Removal

Response Number 2
Name: pqsi
Date: May 7, 2008 at 13:30:51 Pacific
Subject: read a file from a batch file???
Reply: (edit)
Thanks a lot DesX :)

Report Offensive Follow Up For Removal



Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: read a file from a batch file???

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software



Version Tracker Pro
Keep your software current and secure, effortlessly

Click Here for a Free Scan

Driver Agent
Automatically find the latest drivers for your computer.
Click Here for a Free Scan



The information on Computing.Net is the opinions of its users. Such opinions may not be accurate and they are to be used at your own risk. Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE

All content ©1996-2007 Computing.Net, LLC