Computing.Net > Forums > Programming > Monitor folder for .txt file,

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.

Monitor folder for .txt file,

Reply to Message Icon

Name: stopufool
Date: April 19, 2007 at 11:18:35 Pacific
OS: Windows 2003
CPU/Ram: 4gb
Product: ibm
Comment:

I am looking for vbs script that would monitor a certain folder (x:\test) for new .txt files. and if a new .txt file is found an email would be sent out. I would want this script to continue to run so that it would keep monitoring the folder

I saw a script that monitors a folder for new files and copies it to another folder, the script is below, i dunno if it helpts

'Create needed variables
Dim SOURCE, TARGET, waitTime, objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")

'=============================================
'========== USER DEFINED VARIABLES ===========
'=============================================
SOURCE = "x:\Test1"
TARGET = "c:\Test1"
SECONDS = 5 'Time to wait between checking SOURCE
'=============================================
'=============================================

'Verify if source folder exists
If Not (objFSO.FolderExists(SOURCE)) Then
MsgBox "Source Folder Missing"
Else
'Create target directory if does not exist
If Not (objFSO.FolderExists(TARGET)) Then
objFSO.CreateFolder(TARGET)
End If
'Run the moveFiles function
moveFiles
End If

'=============================================
Sub moveFiles
'=============================================
'Copy files from SOURCE to TARGET
objFSO.CopyFolder SOURCE, TARGET

'Delete the TARGET folder (and contents)
objFSO.DeleteFolder SOURCE
'Recreate TARGET folder
objFSO.CreateFolder(SOURCE)

'Wait time before checking SOURCE again
WScript.Sleep SECONDS * 1000

'Recall the moveFiles function
moveFiles

'=============================================
End Sub 'replicateFolders
'=============================================




Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







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: Monitor folder for .txt file,

Move 1.txt file to other folder and www.computing.net/answers/programming/move-1txt-file-to-other-folder-and/16588.html

search for 3 files and create a .txt file www.computing.net/answers/programming/search-for-3-files-and-create-a-txt-file/19141.html

Setting variables from a txt file www.computing.net/answers/programming/setting-variables-from-a-txt-file/15639.html