You've misunderstood the format of a for loop. You also need to use >>
to append to a text file, instead of >
which will write over the file. Going off of your original logic, where InList.txt
will contain all files, and Missing.txt
will only contain missing files:
@echo off
for /f "tokens=*" %%i in (Filelist.txt) DO (
echo %%i>>InList.txt
IF NOT EXIST %%i (echo %%i>>Missing.txt)
)
But if InList.txt
should only contain files that do exist:
@echo off
for /f "tokens=*" %%i in (Filelist.txt) DO (
IF EXIST %%i (echo %%i>>InList.txt) ELSE echo %%i>>Missing.txt
)