Solved

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

Posted on 2013-11-11
4
495 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 51

Accepted Solution

by:
Bill Prew earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Wow, that works perfectly. Thanks for your help, this saved me hours!
0
 
LVL 51

Expert Comment

by:Bill Prew
Comment Utility
Welcome, thanks for the feedback.

~bp
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

744 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

10 Experts available now in Live!

Get 1:1 Help Now