I have a problem here. First things first, the code:
Contents of test.bat:
@echo off
cls
for /F "delims=" %%a in ('dir /B /A-D ^| findstr /I ".txt$"') do (
set str=%%a
echo %str% >> list.tmp
pause
)
echo ------------------
for /F %%i in (list.tmp) do echo %%i
del list.tmp
echo ------------------
In the same directory where test.bat is, there are two test files: 1.txt and 2.txt
When I run test.bat, my output is:
------------------
2.txt
2.txt
------------------
As you can see, 1.txt isn't listed.
And when adding a 3.txt, the output is:
------------------
3.txt
3.txt
3.txt
------------------
Can anyone help me please??
Thanks, Andrew Wong