When diagnosing a larger batch of script that should process files with the extension *.log, I found a funny behavior. In the sample directory with these files:
bar.log
foo.log
foo.log.ignore
foo.log.log-1676521099
not-related
... my little test script:
@echo off
setlocal enabledelayedexpansion
set DEF_LOG="C:\test\*.log"
for %%i in (%DEF_LOG%) do (
echo %%i
)
... prints this:
C:\test\bar.log
C:\test\foo.log
C:\test\foo.log.log-1676521099
Digging deeper, I discovered how Windows templates were created:
C:\>dir "C:\test\*.log" /b
bar.log
foo.log
foo.log.log-1676521099
My question is: how can I list all the files that end with exactly .log?
source
share