Solved

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

Posted on 2014-11-19
4
171 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 68

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 68

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

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

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

746 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