Writing to text file. Need help with errorle

Microsoft Windows vista ultimate w/sp1
October 25, 2011 at 16:18:05
Specs: Windows Vista, p4/3gb
Hello. I have a batch file running each day that updates text files. A few lines might look like this:

echo 477-165, 02-28-2011 >> 1066.doc
echo 477-127, 02-26-2011 >> 102.doc
echo 477-199, 01-01-1995 >> 1055.doc

I would like to have an alert, notification, pause, etc if there was:
1) a problem writing to the .doc file
2) if the .doc file doesn't exist

I tried this:
echo 477-165, 02-28-2011 >> 1066.doc
if errorlevel > 0 echo Problem With 1066.doc

echo 477-127, 02-26-2011 >> 102.doc
if errorlevel > 0 echo Problem With 102.doc

echo 477-199, 01-01-1995 >> 1055.doc
if errorlevel > 0 echo Problem With 1055.doc

But the script just quits when it gets to the 'if' line. Anyone have an idea how I can accomplish this?


See More: Writing to text file. Need help with errorle

Report •


#1
October 26, 2011 at 06:05:08
have you tried using GTR instead of >, in case its syntax?

mike


Report •

#2
October 26, 2011 at 11:27:08
still doesn't seem to work. I found something else that I think will work:

echo 477-165, 02-28-2011 >> 1066.doc || pause..
echo 477-127, 02-26-2011 >> 102.doc || pause..
echo 477-199, 01-01-1995 >> 1055.doc || pause..

It is pausing for me on the errors so I think it'll be good!


Report •

Related Solutions


Ask Question