?
Solved

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

Posted on 2014-11-19
4
Medium Priority
?
184 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
[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
  • 2
4 Comments
 
LVL 70

Accepted Solution

by:
Qlemo earned 2000 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 70

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Progress
Introduction to Processes
Suggested Courses

770 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