0

I am running an program that uni-directly copies from source to destination. The following script runs in conjunction and skips any files with a "date modified" equaling the same day the program is running.

I'd like to modify the script to skip any files with a "created" date equaling today's date and allow any other files regardless of "modified" date.

Essentially, If DateCreated=Today Then Skip

Below is the script I am currently using. I just can not get the right syntax to use creation time verses modified time.

Thank you in advance,


Function Description(ScriptType)
  Description = "Ignores any source files modified today. Not used on Restore."
  ScriptType = 2
End Function

Sub RunBeforeFileCompare(Filename, ByRef Skip)
  ' Ignore if this is a Restore
  If SBRunning.Restore Then Exit Sub

  ' See if the file date is the same as todays date, skip if so
  If DateDiff("d", SBRunning.GetFileDateTime(Filename, TRUE), Date) = 0 Then
    Skip = TRUE
  Else
    Skip = FALSE
  End If
End Sub

ChaosPandion
  • 77,506
  • 18
  • 119
  • 157
  • Im a little lost since i dont see the point of the `Function Description` which returns the same string everytime and accepts a parameter that is always set to 2 but is lost in the scope of the function. In the code snippet you provide I dont see a call to that function either. Anyway... to look at file created time you can use the FileSystemObject as seen here. http://stackoverflow.com/questions/10189321/copy-the-files-with-creation-date-range-using-vbs-in-sub-folder-files-also. You by know means will need all the code but it shows how you can see the file createdtime – Matt Aug 13 '14 at 23:04

1 Answers1

0

The following example illustrates the use of the GetFile method.

filespec: Required. The filespec is the path (absolute or relative) to a specific file.

An error occurs on GetFile method if the specified file does not exist.

JScript

function ShowFileAccessInfo(filespec)
{
    var fso, fle, s;
    fso = new ActiveXObject("Scripting.FileSystemObject");
    fle = fso.GetFile(filespec);
    s = fle.Path.toUpperCase() + "<br>";
    s += "Created: " + fle.DateCreated + "<br>";
    s += "Last Accessed: " + fle.DateLastAccessed + "<br>";
    s += "Last Modified: " + fle.DateLastModified   
    return(s);
}

VBScript

Function ShowFileAccessInfo(filespec)
   Dim fso, fle, s
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set fle = fso.GetFile(filespec)
   s = fle.Path & "<br>"
   s = s & "Created: " & fle.DateCreated & "<br>"
   s = s & "Last Accessed: " & fle.DateLastAccessed & "<br>"
   s = s & "Last Modified: " & fle.DateLastModified   
   ShowFileAccessInfo = s
End Function
JosefZ
  • 28,460
  • 5
  • 44
  • 83