Solved

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

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Beginner to Unreal Engine 4 5 94
How do ASP.NET and MVC work together? 4 63
Windows Updates Batch Files (now with executables!) 32 59
Using Third Party DLL with Access VBA 14 41
A short article about problems I had with the new location API and permissions in Marshmallow
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.

830 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