Computing.Net > Forums > Programming > Search and Record Script

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Search and Record Script

Reply to Message Icon

Name: krobinson
Date: February 24, 2009 at 14:11:56 Pacific
OS: Windows XP
Subcategory: Batch
Comment:

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.



Sponsored Link
Ads by Google

Response Number 1
Name: Holla
Date: February 24, 2009 at 21:34:55 Pacific
Reply:

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!
 )
 


0
Reply to Message Icon

Related Posts

See More


Java website interaction perl help needed



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Search and Record Script

Batch File search and delete file www.computing.net/answers/programming/batch-file-search-and-delete-file/16386.html

Perl search and replace www.computing.net/answers/programming/perl-search-and-replace/14586.html

PhP and ACTION script www.computing.net/answers/programming/php-and-action-script/9181.html