batch to count files in DIR then send email

Microsoft Windows 2003 server - 5 users
July 8, 2009 at 19:30:48
Specs: win2k3 server, quad xeon/ 8gb
Hello all,

I've been trying to get a batch file that will go to
a specified directory count the number of files
(any file and a files with a specific extension,
we're searching multiple dir's) and depending
on which folder is being search do one of the

Any File in the folder send email alert
Particular file (ex: XXX.MAN) in folder send
More then X files in the folder (and and
specific) send alert.

I've found ways to count files in a directory
(files only not folders) and I know how to send
the email alerts using something like bmail but
I don't really know how to get the two linked.

Noob here so please give simple clear
examples with your replies!

Thank you!

See More: batch to count files in DIR then send email

Report •

July 8, 2009 at 23:07:17
Can you post what you already have, so we can see how they can be linked?

Report •

July 15, 2009 at 10:04:14
Ok I get the directory counts using this:

dir "c:\mydir1" /ad /o-d /b | find /c /v "::"

I send out alerts via email using bmail:

c:\bmail.exe -s servername -t emailstosendto (some other switches)

To clarify here is what I need it to do:

1. Count the number of directories
2. If less then specified amount (N) goto :less
3. If more then N goto :delete

: delete will delete N+1 directories (oldest first) so if N is 5 and there are 15 dirs it would delete the oldest 10 and leave the newest 5

:less I can handle from here.

Thank you!

Report •

Related Solutions

Ask Question