Pick_File Function_Modified
(Hibernation Script + Reiterating + Reporter Event Added)
Call Pick_modified()
Public Function Pick_modified()
Dim f1
Set fso = CreateObject("Scripting.FileSystemObject")
strPendingFolder = "
\\tstgnpappw001\IVS_ Automation\Project THOR\Incoming\"
strResponseFileFolder= "\\tstgnpappw001\IVS_ Automation\Project THOR\Outgoing\"
If fso.FolderExists(strPendingFolder) Then
Set fileList = fso.GetFolder(strPendingFolder).Files
filecount = fileList.Count
If filecount = 0 Then
waiting_time = 2
Final_wait_time = waiting_time*60
Wscript.Sleep (Final_wait_time)
Call Stop_Hibernation(waiting_time)
Call Pick_modified()
'Reporter.ReportEvent micWarning,"No Files Present in Incomming Folder","Files not found in
\\tstgnpappw001\IVS_ Automation\Project THOR\Incoming\ location"
End If
Else
'Create the folder
set filesys=CreateObject("Scripting.FileSystemObject")
Set newfolder = filesys.CreateFolder(strPendingFolder)
Call Pick_modified()
' ExitRun
End If
For Each f1 in fileList
filename= f1.name
filetime = f1.DateCreated
new_line = split(filetime," ")
date_revised = split(new_line(0),"/")
new_date=date_revised(0)&date_revised(1)&date_revised(2)
time_revised = split(new_line(1),":")
new_time = time_revised(0)&time_revised(1)&time_revised(2)
final_output_creationtime = new_date&new_time
collective_filename = collective_filename&"-"&filename
saveme = saveme&"_"&final_output_creationtime
excel_file = filename&";"&final_output_creationtime
bundle_excel = bundle_excel&"-"&excel_file
'msgbox excel_file
'msgbox bundle_excel
Next
split_bundle = split(bundle_excel,"-")
split_filetime = split(saveme, "_")
split_filename = split(collective_filename,"-")
refernce_file = split_filetime(1)
For i = 1 to ubound(split_filetime)
If refernce_file > split_filetime(i)Then
refernce_file = split_filetime(i)
' reference_filename = split_filename(i)
Else
reference_filename = split_filename(i)
End If
Next
For i = 1 to ubound(split_bundle)
If Instr(1,split_bundle(i),refernce_file,1) Then
split_Move_file = split(split_bundle(i),"-")
Move_File = split_Move_file(0)
Final_Move_File = split(Move_File,";")
End If
Next
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(strPendingFolder & "\" & Final_Move_File(0) )
fso.MoveFile f,strResponseFileFolder
End Function
'******************Hibernate Function******
Public Function Stop_Hibernation(waiting_time)
yourVariable = DateAdd("n",waiting_time,Time())
msgbox yourVariable
Do Until (time() = yourVariable)
set wsc = CreateObject("WScript.Shell")
wsc.SendKeys ("{SCROLLLOCK 2}")
Loop
Wscript.Quit
End Function
'****************************************
No comments:
Post a Comment