ここで問題があります。まず最初に、コード:
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 ------------------
test.bat と同じディレクトリに、1.txt と 2.txt の 2 つのテスト ファイルがあります。
test.bat を実行すると、出力は次のようになります。
------------------
2.txt
2.txt
------------------
ご覧のとおり、1.txt はリストされていません。
3.txt を追加すると、出力は次のようになります。
------------------
3.txt
3.txt
3.txt
------------------
誰でも私を助けてもらえますか??
ありがとう、アンドリュー・ウォン