Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script to backup files from subfolders based on date

Status
Not open for further replies.

Councilk

MIS
May 14, 2003
72
0
0
US
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



 
Create a folder with the date in the name:

Code:
Set objFSO = CreateObject("Scripting.FileSystemObject")
strDate = Right("0" & Month(Date),2) & Right("0" & Day(Date),2) & Year(Date)
objFSO.CreateFolder ("C:\PDF" & strDate)

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
This worked out just fine for me, sorry for the late response but it's starting to pickup around here
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top