Here is my code (Someone on THIS forum helped me with it it) to rename a file with the current date and time.
What code can I ADD to this that will delete the previous days file??? In other words, I need to delete the contents of c:\schematic\uploads BEFORE renaming and moving my file... Can anyone help?
Dim file1, file2
file1 = "C:\schematic\olnsc_s.csv"
' file2 = "C:\schematic" & year(date) & month(date) & Day(Date) & ".txt"
file2 = "C:\schematic\uploads\Versus." & Year(Date) & Right("0" & Month(Date),2) & Right("0" & Day(Date),2) & ".csv"
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(file1) = true then
If fso.FileExists(file2) = true then
fso.DeleteFile(file2)
End if
fso.MoveFile file1, file2
'else
' msgbox "File does not exist"
End If
Set FSO = Nothing
What code can I ADD to this that will delete the previous days file??? In other words, I need to delete the contents of c:\schematic\uploads BEFORE renaming and moving my file... Can anyone help?
Dim file1, file2
file1 = "C:\schematic\olnsc_s.csv"
' file2 = "C:\schematic" & year(date) & month(date) & Day(Date) & ".txt"
file2 = "C:\schematic\uploads\Versus." & Year(Date) & Right("0" & Month(Date),2) & Right("0" & Day(Date),2) & ".csv"
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(file1) = true then
If fso.FileExists(file2) = true then
fso.DeleteFile(file2)
End if
fso.MoveFile file1, file2
'else
' msgbox "File does not exist"
End If
Set FSO = Nothing