Solved

Create a bat file to search all subdirectories for a set of files

Posted on 2014-11-19
4
179 Views
Last Modified: 2014-11-19
Hi Gurus,

I need to search all sub-directories for a set of files that need to be there in all of them prior to running a load.
can anyone please suggest an easy way to do so..for instance in directory stage, I have 10 sub-directories , and I need to verify each of them have files load1.csv, load2csv, load3.csv.

Thanks a lot for all your help!
0
Comment
Question by:chetan1981
  • 2
  • 2
4 Comments
 
LVL 69

Accepted Solution

by:
Qlemo earned 500 total points
ID: 40452935
There are many ways to do that.
@echo off
set reqfiles=load1.csv load2.csv load3.csv
set numfiles=3
pushd .
for /D %%D in (C:\Stage) do (
  cd /D %%D
  for /F %%C in ('dir %reqfiles" /b ^| find /c /v ""') do if %%C equ %numfile% echo %%D is ok
)
popd

Open in new window

0
 

Author Comment

by:chetan1981
ID: 40453050
Thanks! Any way to change ot so it looks for wildcards as well.

for instance *load1*.csv
0
 
LVL 69

Expert Comment

by:Qlemo
ID: 40453085
Just add the wildcards to the file list, and change the numFiles accordingly.
0
 

Author Comment

by:chetan1981
ID: 40453139
Thanks!
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
This is an explanation of a simple data model to help parse a JSON feed
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

813 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

16 Experts available now in Live!

Get 1:1 Help Now