Hello all, I have a tasks where I need to backup a parent folder monthly and two subfolders daily based on the modified date.
I'm able to get the entire folder copied, but the backup folder needs to have the current month as part of the folder name.
This is what I have so far
============= Code below ===========================
Option Explicit
Const intDaysOld = 1
Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objFolder : Set objFolder = objFSO.GetFolder("C:\PPress")
Dim objSubFolder
Dim dPath : dPath = "C:\PPressBak\PDF"
For Each objSubFolder In objFolder.SubFolders
WScript.echo objSubFolder.DateLastModified
If DateValue(objSubFolder.DateLastModified) < DateValue(Now() - intDaysOld) Then
WScript.Echo objSubFolder.DateLastModified
objSubFolder.Copy dPath
WScript.Echo("Copy completed")
End If
Next
I'm able to get the entire folder copied, but the backup folder needs to have the current month as part of the folder name.
This is what I have so far
============= Code below ===========================
Option Explicit
Const intDaysOld = 1
Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objFolder : Set objFolder = objFSO.GetFolder("C:\PPress")
Dim objSubFolder
Dim dPath : dPath = "C:\PPressBak\PDF"
For Each objSubFolder In objFolder.SubFolders
WScript.echo objSubFolder.DateLastModified
If DateValue(objSubFolder.DateLastModified) < DateValue(Now() - intDaysOld) Then
WScript.Echo objSubFolder.DateLastModified
objSubFolder.Copy dPath
WScript.Echo("Copy completed")
End If
Next