dottiemommy
Technical User
- Jun 8, 2012
- 1
I am new to vbscript (very new) and I am having problems with the logic. I am counting files with a specific extension in a folder then send a message when it reaches the threshold.
'Test for the existence of 8 log files
Option Explicit
'On Error Resume Next
Dim strDirectory, nThreshold, counter, extension, msgtext
Dim objFSO, objFolder, objFile, Logfile
strDirectory = "C:\users\dotties\test"
counter = 0
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strDirectory)
For Each objFile In objFolder.Files
counter = counter + 1
Next
msgtext = "The number of txt files in C:|textfiles is:"
Logfile = "C:\users\dotties\test\*.txt"
Const forReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(Logfile) Then
Else
Set objFile = objFSO.GetFile(Logfile) 'Getting an error on this line
End If
If (counter => 8) Then
'This is where I get confused
objFile.write = "The number of text files is:" & counter & vbcrlf
objFile.close
'Test for the existence of 8 log files
Option Explicit
'On Error Resume Next
Dim strDirectory, nThreshold, counter, extension, msgtext
Dim objFSO, objFolder, objFile, Logfile
strDirectory = "C:\users\dotties\test"
counter = 0
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strDirectory)
For Each objFile In objFolder.Files
counter = counter + 1
Next
msgtext = "The number of txt files in C:|textfiles is:"
Logfile = "C:\users\dotties\test\*.txt"
Const forReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(Logfile) Then
Else
Set objFile = objFSO.GetFile(Logfile) 'Getting an error on this line
End If
If (counter => 8) Then
'This is where I get confused
objFile.write = "The number of text files is:" & counter & vbcrlf
objFile.close