?
Solved

Batch File to match file names to list

Posted on 2008-11-06
2
Medium Priority
?
630 Views
Last Modified: 2012-06-27
Hi. I need to match a list of file names to a search of a specific directory and output a list of unmatched files. It has been suggested to me that this would be easy with a batch file.

What I have is a text file that has a list of filenames, File1.*, File2.* etc and i need a search of a directory,(and all subdirectories) to see if these exist, and if not, save the list of missing filename to a seperate file.

Would a batch file be the best solution? and if so, how would i go about this.

0
Comment
Question by:robd2007
2 Comments
 
LVL 38

Accepted Solution

by:
Shift-3 earned 2000 total points
ID: 22899681
Paste the script below into a text file with a .cmd extension.  Customize the value of the list variable with the location of the file list.  Customize the value of the folder variable with the location of the folder to search under.  Running the script will write output to the text file specified in the log variable.


@echo off
setlocal
 
set list=list.txt
set folder=c:\files
set log=notfound.txt
 
if exist "%log%" del "%log%"
 
for /F "tokens=*" %%G in ('type "%list%"') do (
 dir "%folder%\%%G" /A:-D /B /S > NUL 2>&1
 if errorlevel 1 echo %%G>>"%log%"
)

Open in new window

0
 

Author Comment

by:robd2007
ID: 22899993
Thank you for the accuracy and speed of your response. That works perfectly.

You have made me a happy man :)
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month16 days, left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question