How to show all files in multiple directory trees with a certain pattern?

How to show all files in multiple directory trees with a certain pattern?

Post by Dennis Halv » Thu, 18 Aug 2011 22:57:34



How can I traverse (in a batch file under Win7) whole directory trees and show all matched files with their corresponding path?
Example I want to find all files with the name "java.exe" on partitions C:\ and D:\

The following does not work:

------- searchjava.bat ----------------------
for /R %%a in (C:\*\java.exe D:\*\java.exe) do echo "%%a"
---------------------------------------------

Keep in mind that the path should be prepended like

D:\projects\proj1123\jdk\bin\java.exe

Dennis

 
 
 

How to show all files in multiple directory trees with a certain pattern?

Post by Todd Varg » Fri, 19 Aug 2011 05:59:41




>> How can I traverse (in a batch file under Win7) whole directory trees and
>> show all matched files with their corresponding path?
>> Example I want to find all files with the name "java.exe" on partitions
>> C:\ and D:\

>> The following does not work:

>> ------- searchjava.bat ----------------------
>> for /R %%a in (C:\*\java.exe D:\*\java.exe) do echo "%%a"
>> ---------------------------------------------

>> Keep in mind that the path should be prepended like

>> D:\projects\proj1123\jdk\bin\java.exe

> DIR/b/s c:\java.exe d:\java.exe

The sneaky 'silent' follow-up is back again.

 
 
 

How to show all files in multiple directory trees with a certain pattern?

Post by Todd Varg » Sun, 21 Aug 2011 22:23:10




>> How can I traverse (in a batch file under Win7) whole directory trees
> and show all matched files with their corresponding path?  > Example I
> want to find all files with the name "java.exe" on partitions C:\ and D:\

>> The following does not work:

>> ------- searchjava.bat ----------------------
>> for /R %%a in (C:\*\java.exe D:\*\java.exe) do echo "%%a"
>> ---------------------------------------------

>> Keep in mind that the path should be prepended like

>> D:\projects\proj1123\jdk\bin\java.exe

>> Dennis

> ***   How about:

> FOR %%F IN (C:\ D:\) DO DIR java.exe /S

You forgot to use %%F in the DIR command. Note, DIR in Win7 accepts multiple
paths so this method of using FOR is not required.

ps. beware of the silent follow-up poster

 
 
 

How to show all files in multiple directory trees with a certain pattern?

Post by Tom Laveda » Mon, 22 Aug 2011 00:21:23





> Note, DIR in Win7 accepts multiple paths so this method of using FOR is
> not required.

Works in XP as well (so probably in Vista, too).
_______________________
Tom Lavedas
 
 
 

How to show all files in multiple directory trees with a certain pattern?

Post by Richard Bonn » Sun, 18 Sep 2011 19:33:53





> >> How can I traverse (in a batch file under Win7) whole directory trees
> > and show all matched files with their corresponding path?  > Example I
> > want to find all files with the name "java.exe" on partitions C:\ and D:\
(Snip)

> >> Dennis
> > ***   How about:

> > FOR %%F IN (C:\ D:\) DO DIR java.exe /S
> You forgot to use %%F in the DIR command.

***   D'OH! Thanks for the correction, Todd.

   It should have read:

        FOR %%F IN (C:\ D:\) DO DIR %%Fjava.exe /S

Quote:> Note, DIR in Win7 accepts multiple
> paths so this method of using FOR is not required.

***   Cool. I was unaware that WIN 7 "DIR" had been updated in that
manner.

Quote:> ps. beware of the silent follow-up poster

***   I saw that but don't know to what it refers.

--
         Richard Bonner
http://www.chebucto.ca/~ak621/DOS/

 
 
 

1. Trying to devise a script to delete files using a certain pattern.

16 Jun 01 12:40, you wrote to me:

 JP> The irony is that in fact the 4DOS-related Usenet traffic is not that
 JP> high.

I think it outweighs the Fidonet traffic by a good margin.

 JP> JP Software has successfully managed to kill off all
 JP> user-supported support forums for its products.  It no longer has any
 JP> presence outside of its own private fora (which are made doubly
 JP> difficult to access by JP Software's choice of hosting them with
 JP> media3 and using the buggy and half-baked Lyris software).

OK, then I'll shut down the gate. Will that make you happy?

Tom

--- GoldED+/W32 1.1.5-0613
 * Origin: Ten Forward (1:342/1)

2. Lexmark Z52, W2K, and Office 2000

3. Win 98 Boot disk Help!

4. Searching directory (NOT: file) patterns with XCOPY ????

5. EXPORTING messages to MS Exchange

6. produce list of files in current directory matching pattern

7. Rulers in SW drawings

8. TREE program that shows long names?

9. make error 424: multiple target patterns

10. Copy file to multiple directories

11. Batch file in multiple Directories?

12. Copying multiple files to directory