Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I need help generating a Batch Script that will detect new Files larger that a specified size. I need this to run on an entire volume as the directory structure is created durring the addition of the new files.
Hello from WSU

I plan on running the batch as a scheduled job every hour on a server to check for files being created over a certain size. If the size is too large it will notify an admin.
Hello from WSU

Try this:
:: get sizes of new
@echo offdir \temp\- /s/b/od > newlist
for /f "tokens=*" %%F in (newlist) do (
call :sub1 %%F )
copy newlist oldlist > nul
goto :eof:sub1
find "%*" < oldlist > nul
if not errorlevel 1 goto :eof
if %~Z1 gtr 100 echo %* is %~Z1
goto :eof
:: DONE
=====================================
If at first you don't succeed, you're about average.M2

I tried you script with the following Mods
:: get sizes of new
@echo offdir /s/b/od c:\*.* > newlist
for /f "tokens=*" %%F in (newlist) do (
call :sub1 %%F )
copy newlist oldlist > nul
goto :eof:sub1
find "%*" < oldlist > nul
if not errorlevel 1 goto :eof
if %~Z1 gtr 100000 echo %* is %~Z1
goto :eof
:: DONEIt does not create the oldlist file and gives an file not found error..
Hello from WSU

Did you run it a second time?
[I should have mentioned that.]
=====================================
If at first you don't succeed, you're about average.M2

Sorry it is working... Can you help me further. I would like to send the list of new files to an email address from a Windows 2003 Server to a POP Email account..
Thanks
Hello from WSU

Hi Don,
Something is funky here.
It sounds like your in a situation such that it can't write the file[s]. I can't imagine you're on a write protected floppy.
Look in the directory and see if oldlist and newlist are there.
=====================================
If at first you don't succeed, you're about average.M2

The files are there. And as the earlier post it is working. One issue though it looks to be hung. I started the batch agains my XP pro system C drive and it reported that the oldlist was new which is correct but it is still running 20 Min later.
????
The batch is working but I think it hung. I also need to email the results to a POP email account...
Thanks
Hello from WSU

Hi,
Yeah... Mine is acting up if I do a monster DIR.
I'm working on it.
=====================================
If at first you don't succeed, you're about average.M2

Thanks for the help.. the directory stucture this will be monitoring is a monster...
Hello from WSU

Hi Don,
I think it will require doing one directory at a time.
I'm still at it.
If at first you don't succeed, you're about average.M2

Unfortunatly that will kill my chances I need it to do the entire volume.
Thanks
Hello from WSU

Im confused you said one directory at a time then you said an entire volume. Did you get the proccess to work against a large volume ?
Hello from WSU

Just for information of the Scope we will be dealing with the following and it will grow
104 GB (111,816,606,041 bytes)
1,306,545 Files, 1879 Folders
Hello from WSU

How about using Perl instead of the batch file?
This will print all files names in the volume where the size is greater than 100000 (which is not very big, so you'll have lots of files). It doesn't include the emailing, but that is easy to add.
#!perl
use strict;
use File::Find;my $vol = 'c:';
my @path = '/';find(sub{print $vol,$File::Find::name,$/ if -f and -s > 100000;}, @path);

I was just about to say, before that perl popped in, that the batch is far from complete. Worse yet, it takes everal minutes to do just a few dozen directories.
I think I better drop thios one like a hot french fry and you better go with the perl.
Good luck
If at first you don't succeed, you're about average.M2

![]() |
Batch file to copy from n...
|
How to delete in VB.NET
|

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