Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
535 views
in Technique[技术] by (71.8m points)

scripting - A .bat or .wsh script that can search for files

I am looking for some examples of a .bat OR .wsh script that can do the following:

  • Recursively read file names in a directory with a user-provided extension (.dll, .exe, etc)
  • Search a user-provided directory for the above file names
  • Generate a txt or xls report of the findings, like: x.txt was found in "C:emp", "C:lah"

TIA.

EDIT:

Oops, I should clarify: there are two directories and two searches here.

Search 1:

  • Search a user provided directory "Dir 1" for all *.dll's.

Search 2:

  • Search a different user provided directory "Dir 2" for the file names generated in Search 1. This search also needs to be recursive.

So, if Search 1 finds foo.dll, foo2.dll and foo3.dll in Dir 1, Search 2 should look in Dir 2 for foo.dll, foo2.dll and foo3.dll, and provide a report (simple listing) of each found file.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Why not use dir?

Search current directory and all subdirs for dlls

dir /S *.dll

Search all of C for dlls

dir /S C:*.dll

Save a report

dir /S C:*.dll > report.txt

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...