Solved

Put Search results into a CSV file

Posted on 2006-06-09
16
446 Views
Last Modified: 2010-04-03
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

0
Comment
Question by:wmannix
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
16 Comments
 
LVL 10

Expert Comment

by:GuruGary
ID: 16875482
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
 

Author Comment

by:wmannix
ID: 16876675
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
 
LVL 10

Accepted Solution

by:
GuruGary earned 300 total points
ID: 16877366
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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
LVL 10

Expert Comment

by:stafi
ID: 16877627
here is what you need and more:

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

0
 
LVL 70

Expert Comment

by:garycase
ID: 16878649
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
 

Author Comment

by:wmannix
ID: 16886284
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
 

Author Comment

by:wmannix
ID: 16886450
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
 
LVL 10

Expert Comment

by:GuruGary
ID: 16889594
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
 

Author Comment

by:wmannix
ID: 16896870
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
 
LVL 10

Expert Comment

by:GuruGary
ID: 16897161
Yes, all local drives in that one command, and the results of all drives go to the same output file.
0
 

Author Comment

by:wmannix
ID: 16897989
thanks!
0
 
LVL 10

Expert Comment

by:GuruGary
ID: 16898157
You're welcome.
0
 

Author Comment

by:wmannix
ID: 16901898
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
 
LVL 10

Expert Comment

by:GuruGary
ID: 16902776
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
 

Author Comment

by:wmannix
ID: 16903079
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I previously wrote an article addressing the use of UBCD4WIN and SARDU. All are great, but I have always been an advocate of SARDU. Recently it was suggested that I go back and take a look at Easy2Boot in comparison.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
This tutorial will walk an individual through the process of installing the necessary services and then configuring a Windows Server 2012 system as an iSCSI target. To install the necessary roles, go to Server Manager, and select Add Roles and Featu…
This Micro Tutorial will teach you how to reformat your flash drive. Sometimes your flash drive may have issues carrying files so this will completely restore it to manufacturing settings. Make sure to backup all files before reformatting. This w…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question