Batch script to search for a file in a folder

 batchdude -
I want a batch script which finds for a filename(say "setup.lst" ) in all subfolders and print the folder name in which the file contains. Can anybody help me? its urgent.
Advance Thanks....

2 replies

well I have something defrent , I wanted to do the same thing I think ,
that's my batch :

@echo off
set pth=%*
cd %pth%
title Searching in %pth% and all sub directories .
set LF=
echo ToExit - Don't Search [Hit ENTER]
set /p LF=Looking For :
if x%LF%==x goto eof
dir /s %LF%
echo Done.
goto begin
echo Thank You .

and add to the registry : [HKEY_CLASSES_ROOT\Folder\shell\Search bat\command]
@="\"C:\\Program Files\\Search\\search.bat\" %1"

that's what I have , I use it all the time...
Thank you

A few words of thanks would be greatly appreciated. Add comment

CCM 2821 users have said thank you to us this month

If I want to modify the batch to look for a certain file EVERY time I click it?
try this bat file

@echo off
dir %1 /b /o:gn > "%temp%\Listing"
start /w excel "%temp%\Listing"
del "%temp%\Listing"

It prints to an excel file. Add it to the registry (*.reg) to to opo up on the right click menu

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\Print File Name]

[HKEY_CLASSES_ROOT\Directory\shell\Print File Name\command]
@="printdir2.bat \"%1\""