|I cannot offer you a batch solution but i can offer you a VBA one. The code below reads each line from a text file, checks if the file exists in the source folder, then copies it to a destination folder. What it also does is make a record in Excel of all the files it has found and copied and all those that it couldnt find. |
1) The text file being read has all enteries on a new line, for example
Here is the code.
You will need to modify the paths for 'SourceFolder' and 'DestinationFolder', you will also need to change the path to the file you need to read each line from, this is 'FileName'
Private Sub LetsStart()
Dim FileNum As Integer
Dim ReadLine As String
Dim FileName As String
Dim SourceFolder As String
Dim DestinationFolder As String
Dim NewRow As Integer
SourceFolder = "P:\Source\"
FileName = "P:\PWConvert.txt"
DestinationFolder = "P:\Dest\"
FileNum = FreeFile()
Open FileName For Input As #FileNum
While Not EOF(FileNum)
Line Input #FileNum, ReadLine
If FileExists(SourceFolder & ReadLine) Then
FileCopy SourceFolder & ReadLine, DestinationFolder & ReadLine
NewRow = Sheet1.Range("A" & Rows.Count).End(xlUp).Row
Sheet1.Range("A" & NewRow + 1).Value = ReadLine
NewRow = 0
NewRow = Sheet1.Range("B" & Rows.Count).End(xlUp).Row
Sheet1.Range("B" & NewRow + 1).Value = ReadLine
NewRow = 0
Private Function FileExists(iFile As String) As Boolean
If Dir(iFile) <> "" Then
FileExists = True
FileExists = False
If you PM me your email address i can send you the Excel file with the code.
message edited by AlwaysWillingToLearn