On Tue, Jan 20, 2009 at 1:44 PM, m b <[email protected]> wrote:
> I need to create a section of a batch file that will determine whether a
> folder has had files added to it or not, and then perform one of two
> actions.

  If you're just looking to see if the folder is empty or not, this may help:

        DIR /B %folder% | findstr /R . > NUL

That will return success if %folder% is empty, or failure if %folder%
contains anything at all.  ("Success" being a zero exit code (error
level), and "failure" being a non-zero exit code.)

  If you're actually looking to at directory contents changes, then
yah, you'll need to save previous directory state and compare, like
you spoke of.

>  the "fc" command doesn't seem to give me any output I can use within the 
> batch file

  ???  If my testing, FC.EXE returns success if files are identical,
and failure if they differ.  Win XP Pro SP2.  Demonstration batch
file:

        FC orig.txt same.txt > NUL
        @ECHO ERRORLEVEL=%ERRORLEVEL%
        FC orig.txt diff.txt > NUL
        @ECHO ERRORLEVEL=%ERRORLEVEL%

  That produces this output:

        Ben>FC orig.txt same.txt  1>NUL
        ERRORLEVEL=0

        Ben>FC orig.txt diff.txt  1>NUL
        ERRORLEVEL=1

-- Ben

~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

Reply via email to