Batch compare folder contents to txt file

February 22, 2011 at 08:01:05
Specs: Windows XP
Hi,

I'm trying to create a batch script to open a text file that has a list of files written into it, I then want to compare the files listed in that text file to a folder on my computer. If the file listed in the TXT is NOT in the folder it would print the missing file to another text file.

For example:
c:/allFiles.txt
file1.doc
file2.doc
file3.doc
file4.doc
file5.doc

c:/FilesDirectory
/file1.doc
/file3.doc
/file5.doc

Then after comparing it will create this text file:
c:/missingFiles.txt
file2.doc
file4.doc

Thank you for your help in advance!


See More: Batch compare folder contents to txt file

Report •

#1
February 22, 2011 at 10:09:51
I gues it does what you asked.


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


@echo off
for /f %%a in (allfiles.txt) do (

if exist filesdir\%%a echo file %%a present
if not exist filesdir\%%a (
echo file %%a not present
echo %%a >>missingFiles.txt
)

)

===============================================================`

Subhash Chandra.


Report •

#2
February 22, 2011 at 10:34:17
That does it perfectly! Thanks a lot for your help!

Report •
Related Solutions


Ask Question