There are third party DOS utilities that can do date handling, but left alone, batch code is somewhat lacking in many features...date handling among them.
This little script should help you out:
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("
your foldergoeshere")
Set colSubFolders = f.SubFolders
For Each objFolder in colSubFolders
ShowFiles objFolder
Next
Sub ShowFiles(Fld)
Set k = fso.GetFolder(Fld)
Set s = k.SubFolders
Set kf = k.Files
For Each objFile In kf
If objFile.DateCreated < date - 7 Then
If objFile.Extension = "bak" Then
Wscript.Echo objFile & " " & objFile.DateCreated End If
Next
End Sub
As written the script only lists files. Change the highlighted line to
fso.DeleteFile(objFile). Be sure to change
yourfoldergoeshere with something appropriate (ie: C:\Backup). Save the script with a
vbs extension and run as
cscript scriptname.vbs