File search

  • Thread starter Thread starter Armando
  • Start date Start date
A

Armando

Is there a way to search for files with a specific
extension in a certain directory and all subdirectories
and output the results to a txt file? I am able do a
windows search in explorer for *.extension but the
results are not able to be copied out of the explorer
window.
 
Armando said:
Is there a way to search for files with a specific
extension in a certain directory and all subdirectories
and output the results to a txt file? I am able do a
windows search in explorer for *.extension but the
results are not able to be copied out of the explorer
window.

In a command prompt window type:
dir /s /b x:\mydir\*.ext > MySearch.txt

E.g: dir /s /b c:\bin\*.vbs > MySearch.txt

Woud give you a listing like this
c:\bin\cleansyslog.vbs
c:\bin\clwrapper.vbs
c:\bin\dfrag.vbs
c:\bin\easter.vbs
c:\bin\filesize.vbs
....
c:\bin\scripts\xmlcurrentip.vbs
c:\bin\scripts\xmlfreebies.vbs
c:\bin\scripts\xpping.vbs
c:\bin\ssr13i\ssrtest.vbs


If you prefer the standard dir listing then leave off the /b switch.
Volume in drive C is Firecat
Volume Serial Number is 402D-A313

Directory of c:\bin

10/07/2001 08:31 AM 8,570 cleansyslog.vbs
12/13/2002 02:47 PM 227 clwrapper.vbs
04/12/2003 04:10 AM 916 dfrag.vbs
03/15/2002 07:19 PM 771 easter.vbs
10/14/2002 03:11 PM 319 filesize.vbs
....
 
In said:
Is there a way to search for files with a specific
extension in a certain directory and all subdirectories
and output the results to a txt file? I am able do a
windows search in explorer for *.extension but the
results are not able to be copied out of the explorer
window.

Since this is a "cmdprompt" group use the commandline.

DIR (targetdir)\filespec /s /a >(path)\outfile
 
-----Original Message-----



In a command prompt window type:
dir /s /b x:\mydir\*.ext > MySearch.txt

E.g: dir /s /b c:\bin\*.vbs > MySearch.txt

Woud give you a listing like this
c:\bin\cleansyslog.vbs
c:\bin\clwrapper.vbs
c:\bin\dfrag.vbs
c:\bin\easter.vbs
c:\bin\filesize.vbs
....
c:\bin\scripts\xmlcurrentip.vbs
c:\bin\scripts\xmlfreebies.vbs
c:\bin\scripts\xpping.vbs
c:\bin\ssr13i\ssrtest.vbs


If you prefer the standard dir listing then leave off the /b switch.
Volume in drive C is Firecat
Volume Serial Number is 402D-A313

Directory of c:\bin

10/07/2001 08:31 AM 8,570 cleansyslog.vbs
12/13/2002 02:47 PM 227 clwrapper.vbs
04/12/2003 04:10 AM 916 dfrag.vbs
03/15/2002 07:19 PM 771 easter.vbs
10/14/2002 03:11 PM 319 filesize.vbs
....


.
Thank you, does this search hidden directories and
files? Is there a way to search for files that haven't
been accessed in a certain time period?
 
Armando said:
Is there a way to search for files with a specific
extension in a certain directory and all subdirectories
and output the results to a txt file? I am able do a
windows search in explorer for *.extension but the
results are not able to be copied out of the explorer
window.

Hi

The free Agent Ransack is an option.

Download it from here:
http://www.agentransack.com/default.aspx

Agent Ransack can save the search result to a file (or clipboard), as text,
comma separated text or tab separated text. E.g. Excel reads comma separated
text (csv) very well.

When searching for text inside files, Agent Ransack is also able to do a
preview of the lines the text was found in (just do a single click on the
found file).
Also, you can use regular expression on both the file name part and the find
text in files part.


Karen's Directory Printer (free) is another option, it can save to a file:
http://www.karenware.com/powertools/ptdirprn.asp
 
files? Is there a way to search for files that haven't
been accessed in a certain time period?

For hidden files/dirs do a second run with the /ah switch (attribute
hidden):
dir /s /b x:\mydir\*.ext > MySearch.txt
dir /s /b /ah x:\mydir\*.ext >> MySearch.txt

Notice the use of the double '>>' in the second command. This adds the new
hidden files to MySearch.txt. A single '>' would overwrite the file. If you
really want a hidden directory listing even if there are no files in it then
you'd have to add a 3rd search:
dir /s /b /ahd x:\mydir\*.ext >> MySearch.txt
where /ahd means hidden directory attribute

I use a clone of the UNIX find command for by age searches but I'm sure
somebody here can help you with a cmd script for that.
 
Is there a way to search for files with a specific
extension in a certain directory and all subdirectories
and output the results to a txt file? I am able do a
windows search in explorer for *.extension but the
results are not able to be copied out of the explorer
window.


for /R C:\Folder %%f in (*.txt) do @echo %%f>>Text.txt


Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com
 
Back
Top