Computing.Net > Forums > Programming > Batch to scan for new files

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.

Batch to scan for new files

Reply to Message Icon

Name: Donald Martin
Date: June 30, 2006 at 07:15:40 Pacific
OS: Windows XP / 2003
CPU/Ram: P4
Product: Dell
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: June 30, 2006 at 07:19:08 Pacific
Reply:

How new?


=====================================
If at first you don't succeed, you're about average.

M2



0

Response Number 2
Name: Donald Martin
Date: June 30, 2006 at 07:51:23 Pacific
Reply:

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


0

Response Number 3
Name: Mechanix2Go
Date: June 30, 2006 at 08:48:01 Pacific
Reply:

Try this:

:: get sizes of new
@echo off

dir \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



0

Response Number 4
Name: Donald Martin
Date: June 30, 2006 at 09:09:27 Pacific
Reply:

I tried you script with the following Mods

:: get sizes of new
@echo off

dir /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
:: DONE

It does not create the oldlist file and gives an file not found error..

Hello from WSU


0

Response Number 5
Name: Mechanix2Go
Date: June 30, 2006 at 09:21:47 Pacific
Reply:

Did you run it a second time?

[I should have mentioned that.]


=====================================
If at first you don't succeed, you're about average.

M2



0

Related Posts

See More



Response Number 6
Name: Donald Martin
Date: June 30, 2006 at 09:31:40 Pacific
Reply:

Yes same results

Hello from WSU


0

Response Number 7
Name: Donald Martin
Date: June 30, 2006 at 09:41:58 Pacific
Reply:

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


0

Response Number 8
Name: Mechanix2Go
Date: June 30, 2006 at 09:56:33 Pacific
Reply:

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



0

Response Number 9
Name: Donald Martin
Date: June 30, 2006 at 10:04:14 Pacific
Reply:

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


0

Response Number 10
Name: Mechanix2Go
Date: June 30, 2006 at 10:11:49 Pacific
Reply:

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



0

Response Number 11
Name: Donald Martin
Date: June 30, 2006 at 10:19:42 Pacific
Reply:

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

Hello from WSU


0

Response Number 12
Name: Mechanix2Go
Date: June 30, 2006 at 10:54:52 Pacific
Reply:

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


0

Response Number 13
Name: Donald Martin
Date: June 30, 2006 at 11:40:07 Pacific
Reply:

Unfortunatly that will kill my chances I need it to do the entire volume.

Thanks

Hello from WSU


0

Response Number 14
Name: Mechanix2Go
Date: June 30, 2006 at 12:37:10 Pacific
Reply:

It will do an entire vol.


If at first you don't succeed, you're about average.

M2


0

Response Number 15
Name: Donald Martin
Date: June 30, 2006 at 12:40:37 Pacific
Reply:

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


0

Response Number 16
Name: Mechanix2Go
Date: June 30, 2006 at 12:57:30 Pacific
Reply:

Still working on it.


If at first you don't succeed, you're about average.

M2


0

Response Number 17
Name: Donald Martin
Date: June 30, 2006 at 13:13:11 Pacific
Reply:

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


0

Response Number 18
Name:
Date: June 30, 2006 at 13:59:27 Pacific
Reply:

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


0

Response Number 19
Name: Mechanix2Go
Date: June 30, 2006 at 14:09:30 Pacific
Reply:

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


0

Sponsored Link
Ads by Google
Reply to Message Icon

Batch file to copy from n... How to delete in VB.NET



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: Batch to scan for new files

Need program to scan for a file ..... www.computing.net/answers/programming/need-program-to-scan-for-a-file-/19026.html

Batch code to search for new files www.computing.net/answers/programming/batch-code-to-search-for-new-files/16459.html

batch to extract rows from files www.computing.net/answers/programming/batch-to-extract-rows-from-files/15625.html