Need some help on this script, it works fine if I put in the name of the file and the extension, however I need to script to search for any new files regardless of the file name and file extension... can anyone help with this? I keep getting "No file Exists" every time I run it.
Const startDir = "C:\Test"
Set oFSO = CreateObject("Scripting.FileSystemObject")
DateToday = Year(Date) & Right("0" & Month(Date), 2) & Right("0" & Day(Date), 2)
sFileNameStart = "*."
sFileNameEnd = ".*"
Set objEmail = CreateObject("CDO.Message")
Set oFolder = oFSO.GetFolder(startDir)
sFullFileName = ""
Recurse oFolder
If sFullFileName <> "" Then
sendEmail
Else
WScript.Echo "No File Exists."
End If
Sub Recurse(oFldr)
For Each oSubFolder In oFldr.SubFolders
Recurse oSubFolder
Next
For Each oFile In oFldr.Files
If Left(LCase(oFile.Name), Len(sFileNameStart)) = LCase(sFileNameStart) And _
Right(LCase(oFile.Name), Len(sFileNameEnd)) = LCase(sFileNameEnd) Then
sFullFileName = oFile.Name
Exit Sub
End If
Next
End Sub
Any help on this would be appreciated...
Thanks...
Const startDir = "C:\Test"
Set oFSO = CreateObject("Scripting.FileSystemObject")
DateToday = Year(Date) & Right("0" & Month(Date), 2) & Right("0" & Day(Date), 2)
sFileNameStart = "*."
sFileNameEnd = ".*"
Set objEmail = CreateObject("CDO.Message")
Set oFolder = oFSO.GetFolder(startDir)
sFullFileName = ""
Recurse oFolder
If sFullFileName <> "" Then
sendEmail
Else
WScript.Echo "No File Exists."
End If
Sub Recurse(oFldr)
For Each oSubFolder In oFldr.SubFolders
Recurse oSubFolder
Next
For Each oFile In oFldr.Files
If Left(LCase(oFile.Name), Len(sFileNameStart)) = LCase(sFileNameStart) And _
Right(LCase(oFile.Name), Len(sFileNameEnd)) = LCase(sFileNameEnd) Then
sFullFileName = oFile.Name
Exit Sub
End If
Next
End Sub
Any help on this would be appreciated...
Thanks...