views:

29

answers:

1

Hi,

I am trying to get a batch script to check whether a folder contains any files in it. So far this is how far I have got:

IF EXIST %FILEPATH%\%%i\FromGlobus\%FILE% (

%WINZIP% %FILEPATH%\GlobusEOD\ExtraFiles\%ZIPFILE% -m %FILE%
IF errorlevel 1 goto subBADEND

)

where %FILE% is *.* but what happens is it tries to zip up files even when none exist and therefore fails!

Any tips or ideas?

Thank you

A: 

You may use something like

set VAR=init
for /f %%a in ('dir /b c:\kk\*.*') do set VAR=exists
if %VAR%==exists ...

Not very efficient in case of large directories, but it works.

HTH!

belisarius