I have a script that performs a number of different functions for me including creating a simple log file that indicates what has been done...I would like to adapt this script so that rather than running a slightly modified version that creates a different log file the original will identify that either the log file does not yet exist and it must create one (which it does just fine now) OR the log file is already there so I just need to add my new entries to it. I'll copy in the code for review. I'm sure I'm just overthinking it (or underthinking for that matter) but will appreciate any help you folks can offer...
Code:
Option Explicit
'This is the location of the raw 835 files to be processed
CONST PATH = "\\anh-ssisql\ssiapp\renws\billing\uploadh\"
CONST ForWriting = 2
' declare the various variables
Dim strDate_2_Copy, strShare, strShareB, objLogFile
Dim fso, objFolder, colFiles, objFile, strFile, remitFile, fileDate
Set fso = CreateObject("Scripting.FileSystemObject")
strDate_2_Copy = Now()
'This is the default location the 835 files must be placed in order for the EDI agent to process them
strShare = "E:\inserver6\EDI\edi_start\"
'This is the location the EDI process places the 835 files once they have been processed by the system
strShareB = "E:\inserver6\EDI\edi_backup"
fileDate = Replace(Date(), "/", "") 'used to establish a date variable to be used later in naming the edicopy log file
If fso.FolderExists(PATH) Then 'makes certain that the path defined above exists and then establishes all files in that directory
Set objFolder = fso.GetFolder(PATH)
Set colFiles = objFolder.Files
Else
Wscript.Echo "Can't find the " & PATH & " folder"
Wscript.Quit
End if
set objLogFile = fso.CreateTextFile("E:\inserver6\log\edicopy" & fileDate & ".txt", ForWriting, True)
For Each strFile in colFiles
Set objFile = fso.GetFile(strFile) 'assigns the files to the strFile variable
If fso.GetExtensionName(strFile) = "835" Then 'it will only pull across 835 files from the directory and nothing else
remitFile = objFile.Name 'gets the file name of each file to be used in a later step
If DateDiff("d", objFile.DateLastModified, strDate_2_Copy) < 4 Then 'it will only copy files that have been created in the last 2 days
If Not fso.FileExists(strShareB & "\" & remitFile) Then 'see if file has already been copied and processed if so loop and check the next file
fso.CopyFile strFile, strShare, True 'any files found to meet the above criteria is copied to the edi_start directory
objLogFile.Write "File " & remitFile & " has been copied to the edi_start directory for processing."
objLogFile.WriteLine
Else
objLogFile.Write "File " & remitFile & " has already been processed and will not be copied."
objLogFile.WriteLine
End If
End If
End If
Set objFile = Nothing
Next
Wscript.Quit