Hello i am new to this forum and i need some help
I have this code that search for a filename by name and modified Date,
It will copy the file to a new path and that works.
But while its being copied i want to rename it.
Who can help me
'''''''''''''''''''''''''''''''''''''''''''''''''
'Code
'''''''''''''''''''''''''''''''''''''''''''''''''
'VARIABLES
bPath = "E:\DRIVERS\Groep 2\" 'DESTINATION PATH
aBeginWith = "holdings_" 'FILE BEGINS WITH
aDate = InputBox("Date", "DATE", Date) 'FILES CREATED AFTER THIS DATE
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set fso = CreateObject("Scripting.FileSystemObject")
'SOURCE PATH
Set aPath = fso.GetFolder("E:\DRIVERS\Groep 1\") 'SOURCE PATH
'SEARCH THE FILES AND COPY TO DESTINATION
For Each file In aPath.Files
If RIGHT(file.Name, 4) = ".txt" and Left(file.Name, Len(aBeginWith)) = aBeginWith and DateDiff("d", File.DateLastModified, aDate) = 0 then
file.Copy bPath & file.name
'objFSO.MoveFile "E:\DRIVERS\Groep 2\holdings_********.txt" , "E:\DRIVERS\Groep 2\test.txt"
End If
Next
I have this code that search for a filename by name and modified Date,
It will copy the file to a new path and that works.
But while its being copied i want to rename it.
Who can help me
'''''''''''''''''''''''''''''''''''''''''''''''''
'Code
'''''''''''''''''''''''''''''''''''''''''''''''''
'VARIABLES
bPath = "E:\DRIVERS\Groep 2\" 'DESTINATION PATH
aBeginWith = "holdings_" 'FILE BEGINS WITH
aDate = InputBox("Date", "DATE", Date) 'FILES CREATED AFTER THIS DATE
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set fso = CreateObject("Scripting.FileSystemObject")
'SOURCE PATH
Set aPath = fso.GetFolder("E:\DRIVERS\Groep 1\") 'SOURCE PATH
'SEARCH THE FILES AND COPY TO DESTINATION
For Each file In aPath.Files
If RIGHT(file.Name, 4) = ".txt" and Left(file.Name, Len(aBeginWith)) = aBeginWith and DateDiff("d", File.DateLastModified, aDate) = 0 then
file.Copy bPath & file.name
'objFSO.MoveFile "E:\DRIVERS\Groep 2\holdings_********.txt" , "E:\DRIVERS\Groep 2\test.txt"
End If
Next