M
Mak
Hi,
In part of a batch, I need to evaluate if two (maybe three) text files with
known names exist in the current folder and if they are, check they are not
empty.
The first part is easy, but I got stuck on the second.
Ideally, I'd like batch to stop checking and do something as soon as the
first 0 bytes file found, but this isn't critical, there won't be many files
in this folder, I can live with evaluating every single file.
I have isolated second part into this:
@echo off
setlocal
set crap=
for %%i in (*) do (
set crap=%%~zi
call :check
)
goto end
:check
if %crap% EQU 0 (
echo found
pause
)
goto:eof
:end
endlocal & goto:eof
The above works, but I have the feelings it can be done differently, better.
For some reason I'm in mental block with this task, hence asking for help.
Oh, and I'd like to avoid using enabledelayedexpansion (if possible),
external files and utilities. OSes this batch needs to work on: W2k, XP and
W2k3.
In part of a batch, I need to evaluate if two (maybe three) text files with
known names exist in the current folder and if they are, check they are not
empty.
The first part is easy, but I got stuck on the second.
Ideally, I'd like batch to stop checking and do something as soon as the
first 0 bytes file found, but this isn't critical, there won't be many files
in this folder, I can live with evaluating every single file.
I have isolated second part into this:
@echo off
setlocal
set crap=
for %%i in (*) do (
set crap=%%~zi
call :check
)
goto end
:check
if %crap% EQU 0 (
echo found
pause
)
goto:eof
:end
endlocal & goto:eof
The above works, but I have the feelings it can be done differently, better.
For some reason I'm in mental block with this task, hence asking for help.
Oh, and I'd like to avoid using enabledelayedexpansion (if possible),
external files and utilities. OSes this batch needs to work on: W2k, XP and
W2k3.