Solved

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

Posted on 2013-11-11
4
505 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 56

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 9

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 56

Expert Comment

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

~bp
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_2459…
Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
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…

617 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