[Last Call] Learn how to a build a cloud-first strategyRegister Now


Scan folder for files and return a box that says new files available

Posted on 2012-08-21
Medium Priority
Last Modified: 2012-08-22

I am looking for a script that can scan a folder and if there are new files within a certain time frame it will pop up a message box with a statement that says, "new files have arrived" or something similar.

Thank you.
Question by:cbones
  • 2
LVL 65

Expert Comment

ID: 38318734

Do you want a script to constantly monitor the folder (which is resource intensive)?  Or just to check whether files have been added in the last hour?


Author Comment

ID: 38318812

Looking for a script to check a folder every 15 minutes and if something new came in prompt that there are new files.
I can add a script to the task scheduler but can the script only respond if new files came in since 15 minutes before?

Thank you.
LVL 65

Accepted Solution

RobSampson earned 1600 total points
ID: 38318844
The task schedular isn't quite that granular, but you could have a script run every hour, for an hour (or 45 minutes more accurately) and make the check.

See how this goes.  For testing, run it manually using
cscript C:\Scripts\CheckFolder.vbs

I haven't tested it at all, so hopefully it works out.



strFolder = "C:\Temp"
' Specify the interval in minutes.  The script will run for one hour, checking the folder every X minutes
intInterval = 15

dteStartTime = Now
dteEndTime = DateAdd("n", -(intInterval-1), DateAdd("h", 1, dteStartTime))

Set objFSO = CreateObject("Scripting.FileSystemObject")
While Now < dteEndTime
	dteLatestFile = CDate("01-01-1601")
	For Each objFile In objFSO.GetFolder(strFolder).Files
		If objFile.DateLastModified > dteLatestFile Then
			dteLatestFile = objFile.DateLastModified
			strLatestFile = objFile.Path
		End If
	If dteLatestFile > CDate("01-01-1601") Then WScript.Echo "Files have been added to " & strFolder & " in the last " & intInterval & " minutes."
	WScript.Sleep intInterval * 60000

Open in new window


Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month17 days, 23 hours left to enroll

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question