Check directory files against txt file

March 13, 2011 at 14:39:51
Specs: Windows XP
Hi,

I have a txt file with a list of file names in it. I would like to take a directory on my computer and find which files in that directory are NOT in the list and put it into another txt file.

For example if my original text file (filelist.txt) reads:

"file 1.txt"
"file 3.txt"
"file 4.txt"

My directory (FileDir) has:
"file 1.txt"
"file 2.txt"
"file 3.txt"
"file 4.txt"
"file 5.txt"

The script would print out a text file (missingfiles.txt) something like this:
"file 2.txt"
"file 5.txt"

Thank you in advance!


See More: Check directory files against txt file

Report •

#1
March 16, 2011 at 14:42:50
check this out.


===========================

@echo off & cls & setlocal enabledelayedexpansion

for /f "tokens=*" %%a in ('dir /b ^| find /i /v "filelist.txt" ^| find /i /v "pk.bat"') do (
echo checking whether file %%a present in the list.
findstr /i "%%a" filelist.txt
if !errorlevel! == 0 echo File Already present in your filelist.
if !errorlevel! == 1 echo %%a >>missingfiles.txt

pause
)

==============================================

Subhash Chandra.


Report •
Related Solutions


Ask Question