Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 236
  • Last Modified:

Folder Monitoring question?

Does anyone know of a good way to monitor a folder for file number of files it contains?  I have a server that I need to watch a certain folder that if the number of files in it exceeds a certain number, I'll get an email.  I don't care about file types, I just need to be alerted if the number of files in this server exceeds a certain threshold.  I've tried automate to do it, but that didn't work out to well.  Does anyone have a better way or know of a good software package that would do it?  Hopefully free!

thanks
0
MCPJoe
Asked:
MCPJoe
  • 6
  • 5
1 Solution
 
woodas26Commented:
Hi MCPJoe.  This software package looks pretty good.  (Not free, though)

http://www.watchdirectory.net/index.html

I'll keep looking and see if I can find a free one.
0
 
MCPJoeAuthor Commented:
That looks like it will do the job, but I am hoping to find a free way to do it.  Even if its VB or something, I don't need anything fancy, just an email alert based on the number of folder items.  

Thanks
0
 
TheCleanerCommented:
This script will count the number of files in a given folder and return the value in an email:


Dim objFSO
Set objFSO = CreateObject("Scripting.filesystemObject")

'Get the folder object associated with the directory
Dim objfolder
Set objfolder = objFSO.Getfolder("C:\My Downloads")

'Loop through the files collection
Dim objFile, fileCount
fileCount = 0
For Each objFile In objfolder.files
fileCount = fileCount + 1
Next

Set objEmail = CreateObject("CDO.Message")

objEmail.From = "TheCleaner@test.com"
objEmail.To = "TheCleaner@test.com"
objEmail.Subject = "File count of c:\My Downloads"
objEmail.Textbody = fileCount
objEmail.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "10.10.10.8"
objEmail.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send


You will need to change:
C:\my downloads = directory to check
email to and from
smtpserver (your exchange server)

That's it...
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
TheCleanerCommented:
oops...forgot you wanted it only if it exceeds...

So you can say right about "set objEmail":

IF fileCount > 30 Then


(then put End IF below the objEmail.Send)
0
 
TheCleanerCommented:
oops again...dang it...the "right about" above should be "right above"
0
 
MCPJoeAuthor Commented:
Is there any special software that needs to be installed for this work?  Could I run this as a ask in task manager?  Also, how does the email sending work, or would it be possible to specify an SMTP server and port with credentials?  I'll give this a try.  

Thanks
0
 
TheCleanerCommented:
It's simple vbscript.  save it as a .vbs file.  You can run it as a task in task manager at specified times as needed.

The email sending works using Collaboration Data Objects, built into the OS, no software required.  All that is needed is to have access to the SMTP server in your organization.  No credentials are required.
0
 
MCPJoeAuthor Commented:
Usually no credentials are required, but I don't have access to any unsecured SMTP servers.  I need to be able to specify credentials to authenticate to an SMTP server.  Is there any way to do that?  Otherwise I think the script is working, the only errors I get are with connecting to an SMTP server.

Thanks
0
 
MCPJoeAuthor Commented:
Also, is there a way to customize the body of the message to add more text than just the file count?  I tried to add a quoted text but I get an error when running the script.
0
 
TheCleanerCommented:
What kind of SMTP server do you have?  What's the exact error you get?

Yes, you can add text to the body...it would be in the following fashion:

objEmail.Textbody = "Total number of files in the folder = " & fileCount
0
 
MCPJoeAuthor Commented:
Thanks so much, that works perfectly.  This is exactly what I was looking for.  

Thanks again
0
 
TheCleanerCommented:
Very welcome...

For future reference, this part in the script:

Set objEmail = CreateObject("CDO.Message")

objEmail.From = "TheCleaner@test.com"
objEmail.To = "TheCleaner@test.com"
objEmail.Subject = "File count of c:\My Downloads"
objEmail.Textbody = fileCount
objEmail.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "10.10.10.8"
objEmail.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send


Can be used in any vbscript (basically just changing the from, to, subject, and textbody).  So keep that part handy to add to other scripts you need to get emails from.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now