You should use a combination of dir
with the /B
flag and findstr
@echo off
setlocal enabledelayedexpansion
set "zipMask=ZipForCloudMaster ????-??-??_??-??-??.zip"
set "zcnt=0"
REM Use dir and pipe through findstr to handle the specific pattern
for /f "delims=" %%A in ('dir /b /a-d ^| findstr /r /i "^ZipForCloudMaster [0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]_[0-9][0-9]-[0-9][0-9]-[0-9][0-9]\.zip$"') do (
if !zcnt!==0 echo Zip files present:
echo %%A
set /a zcnt+=1
)
if !zcnt!==0 (
echo WARNING: Older zip files found. Proceeding will include these in the new zip.
) else (
echo No older zip files found. Safe to proceed.
)