Greg,
Here is a variation. It does go into sub-directories though.
'---------------------------------------------------------------------------
Sub CopyFolder()
'---------------------------------------------------------------------------
Dim oFSO As Object
Dim sFolder As String
Dim oFolder As Object
Dim oFile As Object
Set oFSO = CreateObject("Scripting.FileSystemObject")
sFolder = "I:\Backup\"
If Not oFSO.FolderExists(sFolder) Then
MkDir sFolder
End If
If Not oFSO.FolderExists(sFolder & Format(Date, "yyyy-mm-dd")) Then
MkDir sFolder & Format(Date, "yyyy-mm-dd")
End If
Set oFolder = oFSO.getfolder("C:\idsc\")
For Each oFile In oFolder.Files
If Int(oFile.DateLastModified) = Date Then
oFile.Copy sFolder & Format(Date, "yyyy-mm-dd") & "\" &
oFile.Name
End If
Next oFile
Set oFile = Nothing
Set oFolder = Nothing
Set oFSO = Nothing
End Sub
--
HTH
RP
(remove nothere from the email address if mailing direct)
"Greg B" wrote in message
...
Hi I received this code from Bob Phillips and it does what I want except
it
copies everything I want to the "I drive" it makes a folder with today's
date. What I need it to do is actually copy all the items into the
directory with today's date.
'---------------------------------------------------------------------------
Sub CopyFolder()
'---------------------------------------------------------------------------
Dim oFSO As Object
Dim sFolder As String
Set oFSO = CreateObject("Scripting.FileSystemObject")
sFolder = "I:\backup\"
If Not oFSO.FolderExists(sFolder) Then
MkDir sFolder & Format(Date, "yyyy-mm-dd")
End If
If Not oFSO.FolderExists(sFolder & Format(Date, "yyyy-mm-dd")) Then
MkDir sFolder & Format(Date, "yyyy-mm-dd")
End If
oFSO.CopyFolder "C:\idsc\*", sFolder & "\"
Set oFSO = Nothing
End Sub
Thanks again
Greg
|