Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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
'=============================================

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |