Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!yale!mintaka!ogicse!intelhf!int13!tim From: tim@int13.hf.intel.com (Timothy E. Forsyth) Newsgroups: comp.windows.ms Subject: Re: Zero byte DOS files Message-ID: <839@int13.hf.intel.com> Date: 31 Aug 90 15:46:19 GMT References: <23366@sequoia.execu.com> Distribution: na Organization: Intel Corp., Oregon MicroComputer Division, Hillsboro, OR Lines: 81 jam@sequoia.execu.com (James LeBas) writes: >Does anybody know how to get a .bat file to test for the length of another >file; specifically, for the presence of a zero byte file? With normal DOS batch commands, NO. [The following batch line produces empty errlst even if goodfile.txt exists.] > if not exist goodfile.txt echo goodfile.txt missing >> errlist ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^ I believe the relationship between the IF and >> is as I have marked above. There are two ways to keep from creating the errlist file, in the first all commands are in the same batch file; in the second you create a secondary batch file. Example 1: TEST.BAT IF NOT EXIST goodfile.txt GOTO missing GOTO continue :missing ECHO goodfile.txt missing >> errlist :continue Example 2: TEST.BAT IF NOT EXIST goodfile.txt CALL missing.bat goodfile.txt MISSING.BAT ECHO %1 missing >> errlist If you are going to be checking for the existance of a lot of files, I suggest you creat a batch file CHKEXIST.BAT which is a modification on example 1. TEST.BAT CALL chkexist.bat file1.txt . . . CALL chkexist.bat file2.txt . . . CALL chkexist.bat file2.txt CHKEXIST.BAT IF NOT EXIST %1 GOTO missing GOTO end :missing ECHO %1 missing >> errlist :end Hope this is of some help. Tim Forsyth (Disclaimer: This is just sharing of my own experiences with DOS batch files, and has nothing to do with my employer, Intel Corp.) -- Tim Forsyth, tim@int13.hf.intel.com or forsytim@ccm.hf.intel.com Intel Corp., Oregon MicroComputer Division, Hillsboro, Oregon, USA