Solved

Search for files in a list and output file path to log file

Posted on 2013-11-11
4
496 Views
Last Modified: 2013-11-11
Hi experts

I am looking for a script that will achieve the following:

- loop through a specific folder on a Windows 7 PC (e.g. FileName1.pdf, FileName2.pdf, etc)
- search for a list of files (approx. 50 file names)
- output all file paths to a single log file, one line per file
e.g.
c:\SomeFolderName\FileName1.pdf
c:\SomeFolderName\SubFolder\Subfolder\FileName2.pdf
c:\SomeFolderName\SubFolder\FileName3.pdf
c:\SomeFolderName\SubFolder\FileName4.pdf
etc


Thanks
0
Comment
Question by:riffrack
  • 2
4 Comments
 
LVL 52

Accepted Solution

by:
Bill Prew earned 500 total points
ID: 39638532
Here is a relatively simple and easy way to do this with a BAT script.  Adjust the SET lines at the top to reference the base folder to search, and the file that contains the list of files.

Accuracy can be increased if you start each line in the list file with a backslash.

@echo off
set BaseDir=c:\temp
set Filelist=files.txt
dir /a-d /b /s "%BaseDir%\*.*" | findstr /i /e /g:"%Filelist%"

Open in new window

~bp
0
 
LVL 7

Expert Comment

by:Murugesan Nagarajan
ID: 39638546
Try with
dir /s /b *.pdf

Open in new window

From command
help dir

Open in new window

/B          Uses bare format (no heading information or summary).
/S          Displays files in specified directory and all subdirectories.
0
 

Author Closing Comment

by:riffrack
ID: 39638688
Wow, that works perfectly. Thanks for your help, this saved me hours!
0
 
LVL 52

Expert Comment

by:Bill Prew
ID: 39638728
Welcome, thanks for the feedback.

~bp
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

914 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now