Solved

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

Posted on 2013-11-11
4
501 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 54

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 54

Expert Comment

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

~bp
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Date variable in batch file 2 80
Remote start and stop of service 3 69
check the file dates in unix 14 76
Script to delete files using a wild card in the folder string 8 41
Over the years I've spent many an hour playing on hardened, DMZ'd servers, with only a sub-set of the usual GNU toy's to keep me company; frequently I've needed to save and send log or data extracts from these server back to my PC, or to others, and…
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…
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…

738 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