Solved

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

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
jboss 7.1 start up error 1 80
Restore Windows 7 Snipping Tool function to Windows 10 10 102
Java List 4 71
Capturing LPT1 output XP 6 26
This is about my first experience with programming Arduino.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
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…

740 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