Search and Record Script

February 24, 2009 at 14:11:56
Specs: Windows XP
Hello I am looking for a script that will search a computer for multiple files based on file extension (ex. .mps, .pic, .bmp, .avi). I was wondering if there was a way to create a scritp to do this and to export it to a file labeled with the name of the computer or something logical. My boss is leaning hard on me to get this done in a large network where I am managing over 500 computers on several networks. Anyone have any suggestions. I am at a loss to say the least.

See More: Search and Record Script

Report •


#1
February 24, 2009 at 21:34:55
if you name the following batch file netf.bat
invoking it with 'netf *.mp3;*.pic;*.avi'
will list all those files on all computers' shared folders on your network that are accessable to your logged in username.

@echo off
FOR /F "skip=3 eol=T" %%I IN ('net view') do @echo %%I >> %temp%\netview.txt
FOR /F "eol=T delims= " %%i IN (%temp%\netview.txt) do call :FindDir %%i %1
goto :eof
:FindDir
net view %1 > %temp%\netview1.txt
FOR /F "skip=7 tokens=1,2" %%I IN (%temp%\netview1.txt) do if %%J==Disk (
 echo dir /s /b %1\%%I\%2;%3;%4;%5;%6;%7;%8;%9
 dir /s /b %1\%%I\%2;%3;%4;%5;%6;%7;%8;%9
)

--
Holla.

[Edit]
Sorry, I posted too early...
Correct script should be like this...

@echo off
setlocal enableDelayedExpansion
FOR /F "skip=3 eol=T" %%I IN ('net view') do @echo %%I >> %temp%\netview.txt
FOR /F "eol=T delims= " %%i IN (%temp%\netview.txt) do call :FindDir %%i %*
goto :eof
:FindDir
net view %1 > %temp%\netview1.txt
set Machine=%1
FOR /F "skip=7 tokens=1,2" %%I IN (%temp%\netview1.txt) do if %%J==Disk (
 set cmd2suffix=
 set Shd=%%I
 :AddParam
 if "%2"=="" goto OutofLoop
 set cmd2suffix=!cmd2suffix!;!Machine!\!Shd!\%2
 shift
 goto :AddParam
 :OutofLoop
 echo dir /s /b !cmd2suffix!
 dir /s /b !cmd2suffix!
 )
 


Report •
Related Solutions


Ask Question