Solved

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

Posted on 2013-11-11
4
500 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 53

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 53

Expert Comment

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

~bp
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

830 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