Public Sub Sample()
Dim FSO As Object
Dim DataDir As Object
Dim myFiles As Object
Dim fl As Object
Dim myPath As String
Dim oldFile As String
Dim newFile As String
Set FSO = CreateObject("Scripting.FileSystemObject")
myPath = ThisWorkbook.Path & "\data"
Set DataDir = FSO.GetFolder(myPath)
Set myFiles = DataDir.Files
For Each fl In myFiles
oldFile = myPath & "\" & fl.Name
newFile = myPath & "\" & "s_" & fl.Name
FileCopy oldFile, newFile
Kill oldFile
Next fl
End Sub
|