Avatar of chetan1981
chetan1981
 asked on

bat file to scan sub directories to check for set of files

Hi,
I am trying to search all subdirectories in a folder C:\Stage, for a set of files.
File names differ based on the source they come form, for example, load1.csv, load 14.csv, load 21.csv.
So I need to look for files based on load*.csv, import*.csv, etc.

I got the below for QLemo, but need to modify the hardcoded file names to wldcard ones.

Thanks!


@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
Windows Batch

Avatar of undefined
Last Comment
Bill Prew

8/22/2022 - Mon
chetan1981

ASKER
Also just to add, there Directories are on a UNC path, dong a pushd to a UNC path errors out, any workarouund.
Really appreciate any help I can get, I have no expertise in DOS.

Thanks.
ASKER CERTIFIED SOLUTION
SStory

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Bill Prew

What do you want to do when you find the files?

~bp
SOLUTION
Bill Prew

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23