Cappper
asked on
VBScript - Ignore any source files with today's date
I'm not a VBScript expert and I just cant seem to get the right variable.
Below is a script that Ignores any source files not modified yesterday.
I am trying to tweak this so that Ignores any source files modified today.
So if I run the script on April 4th, 2012 it will ignore any file modified with a date of April 4th, 2012.
Any help would be great.
Function Description(ScriptType)
Description = "Ignores any source files not modified yesterday. Not used on Restore."
ScriptType = 2
End Function
Sub RunBeforeFileCompare(Filen ame, ByRef Skip)
' Ignore if this is a Restore
If SBRunning.Restore then
Exit Sub
End If
YesterdayDate = Date - 1
YesterdatStr = CStr(Year(YesterdayDate)) & CStr(Month(YesterdayDate)) & CStr(Day(YesterdayDate))
FileDate = SBRunning.GetFileDateTime( Filename, TRUE)
FileStr = CStr(Year(FileDate)) & CStr(Month(FileDate)) & CStr(Day(FileDate))
If FileStr = YesterdatStr then
Skip = FALSE
Else
Skip = TRUE
End If
End Sub
Below is a script that Ignores any source files not modified yesterday.
I am trying to tweak this so that Ignores any source files modified today.
So if I run the script on April 4th, 2012 it will ignore any file modified with a date of April 4th, 2012.
Any help would be great.
Function Description(ScriptType)
Description = "Ignores any source files not modified yesterday. Not used on Restore."
ScriptType = 2
End Function
Sub RunBeforeFileCompare(Filen
' Ignore if this is a Restore
If SBRunning.Restore then
Exit Sub
End If
YesterdayDate = Date - 1
YesterdatStr = CStr(Year(YesterdayDate)) & CStr(Month(YesterdayDate))
FileDate = SBRunning.GetFileDateTime(
FileStr = CStr(Year(FileDate)) & CStr(Month(FileDate)) & CStr(Day(FileDate))
If FileStr = YesterdatStr then
Skip = FALSE
Else
Skip = TRUE
End If
End Sub
have you tried, post your remarks pl.
ASKER
No. It did not work. When the script is enabled only folders get copied to the destination. No files get copied regardless of the date. When I disable the script all files get copied.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Bill,
Almost perfect. Your script only copied files with today's date instead of ignoring them. As soon as I reversed the True and False statements it worked perfectly.
Thank you.
Almost perfect. Your script only copied files with today's date instead of ignoring them. As soon as I reversed the True and False statements it worked perfectly.
Thank you.
Ah yes, I see I was reading the original wording backwards. Glad you sorted that out and it was useful, thanks.
~bp
~bp
You can try this,
Function Description(ScriptType)
Description = "Ignores any source files not modified today. Not used on Restore."
ScriptType = 2
End Function
Sub RunBeforeFileCompare(Filen
' Ignore if this is a Restore
If SBRunning.Restore then
Exit Sub
End If
ToDate = Date
TodatStr = CStr(Year(ToDate)) & CStr(Month(ToDate)) & CStr(Day(ToToDate))
FileDate = SBRunning.GetFileDateTime(
FileStr = CStr(Year(FileDate)) & CStr(Month(FileDate)) & CStr(Day(FileDate))
If FileStr = TodatStr then
Skip = FALSE
Else
Skip = TRUE
End If
End Sub
'-------------------------
Have a nice day.
from
Karunamoorthy