Just an fyi, you should try to avoid the practice of having a space
before and after the > of a redirection. In certain circumstances, it
can alter or invalidate what you are trying to do.

Also, using ">NUL 2>&1" instead of ">NUL"will nullify error condition
output as well as normal output.  This can be benefitial when you dont
care to see the verbose error msg when you are also trapping the
%ERRORLEVEL%, etc, or performing a function that has no concern for
such output.

--
ME2



On Tue, Jan 20, 2009 at 3:25 PM, Ben Scott <[email protected]> wrote:
> 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/>  ~
>

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

Reply via email to