Put Search results into a CSV file

Is there a way to do a search of local drives and put the result into a csv file?
I want to fild all files on local drives larger than 20mb.
I need to have filename, size, modified, location

wmannixAsked:
Who is Participating?
 
GuruGaryCommented:
No problem.  Here is a batch file that should do what you want.  If you are not familiar with batch files, you can use NOTEPAD to create the file.  For example use Start -> Run -> "notepad c:\searchdrives.bat"
Then paste the code below into NOTEPAD, and File -> Save
Then you can browse to your C: drive, and double-click on SEARCHDRIVES.BAT

You can change the SEARCHSIZE and OUTPUT near the top of the file for your desired results.  Note that if the specified OUTPUT file exists when you run this batch file, it will be deleted and replaced with these new results.  Also note that searching entire hard drives can take several minutes depending on the size of the drive and the number of files on the drive.  If you need a different format, or have any questions, just let us know.  This uses format:
Filename,filesize,filedate,filepath


@echo off
setlocal
set SearchSize=20971520
set Output=C:\Results.csv

if exist %Output% del %Output%
for %%a in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do (
   fsutil fsinfo drivetype %%a: | findstr -i fixed && call :SearchDrive %%a
   )
echo Complete.  Results stored in %Output%
goto :EOF

:SearchDrive
echo Searching %1:
for /f "tokens=*" %%d in ('dir %1:\ /s /a-d /b') do if %%~zd GTR %SearchSize% echo %%~nd,%%~zd,%%~td,%%~dd%%~pd >>%Output%
goto :EOF
0
 
GuruGaryCommented:
Yes, it can be done.  VBScript or a batch file could probably do it the easiest.  Batch file would use the FSUTIL command to get the list of local drives, then use a DIR command in a FOR /F loop to build your CSV file with %~z for size and %~t for modified timestamp of the file.  I doubt you will find somebody to write the code for 50 points, though.
0
 
wmannixAuthor Commented:
It's a fairly important problem for us.  Re-assessed point value.  I'm new to this, and not sure how the whole point thing works.
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
stafiCommented:
here is what you need and more:

http://www.raxco.com/products/diskstate/

0
 
Gary CaseRetiredCommented:
Here's a simple FREE program that will find all files matching your specifications (> 20 MB):
http://www.freebyte.com/disktective/

This one's not free, but does have a free trial version -- and will export to Excel format (as you asked for):
http://www.spadixbd.com/dsm/index.htm
0
 
wmannixAuthor Commented:
I'm more apt to go w/ the batch file option so I don't have to install anything on the servers...
I do have one question though:
Is
  for %%a in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do (
   fsutil fsinfo drivetype %%a: | findstr -i fixed && call :SearchDrive %%a
   )
to identify the local drive letter?  or is that for networked drives?


Thanks for all the rapid responses folks.
0
 
wmannixAuthor Commented:
Also....
I just ran the batch job...
I have results.  It's great.  But.  I have no file extensions.  I have the option on in explorer to view them, and system files.  But it doesn't have them in the resultant data.
0
 
GuruGaryCommented:
Hi, Wmannix.  The FOR loop you asked about is to detect the drive type of each drive letter and only run on local drives (not network).

Sorry about the missing file extensions.  That was an oversight on my part.  Use the following as a replacement for the 2nd FOR loop (just had to add the extension modifier):

for /f "tokens=*" %%d in ('dir %1:\ /s /a-d /b') do if %%~zd GTR %SearchSize% echo %%~nd%%~xd,%%~zd,%%~td,%%~dd%%~pd >>%Output%

If have any other questions, just let us know.
0
 
wmannixAuthor Commented:
Not a problem.  Thanks for the extra info.
That worked out perfectly.
This will search all local drives at once.  Correct?

thanks again.
-W
0
 
GuruGaryCommented:
Yes, all local drives in that one command, and the results of all drives go to the same output file.
0
 
wmannixAuthor Commented:
thanks!
0
 
GuruGaryCommented:
You're welcome.
0
 
wmannixAuthor Commented:
I just ran this on the 1st server.  'FSUTIL' is not recognized as an internal or external command, operable command or batch file.

this is 2000 server.

I have copied fsutil.exe from my XP pro machine to a server (Non Production) and the searchdrives does work.

Will there be adverse affects using fsutil on the 2k box?
0
 
GuruGaryCommented:
I don't think there will be any adverse affects.  The FSUTIL is included with Windows XP, Windows 2003, but MS came out with the utility after the release of Windows 2000.  It should work fine.
0
 
wmannixAuthor Commented:
I found a KB article (about 3 min ago) that uses FSUtil from 2k3 or XP to complete a chkdsk function on a 2k server.  So MS supports the use of it in 2k.
Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.