Check folder name and copy

Juolupuki

Registered User.
Local time
Today, 19:00
Joined
Jan 3, 2018
Messages
31
Hello,

I'm after little help again here :/

What I'm trying to do is to loop folder from temp location and check against main location folders, if it match copy over to main location. I managed to get working code, if there is no folder in main location or it's an exact match.

What i would like to get is to copy folder on folder name partial match.
For example :
tmpFolder\123 to mainFolder\ABC_123

Code:
Private Sub btn_Move_Click()

Dim DirNameFrom As String
Dim PathNameFrom As String
Dim PathNameTo As String

    PathNameFrom = "W:\Absence Database\Absence_BE\HRMove\"
    DirNameFrom = Dir(PathNameFrom, vbDirectory)

    Do While DirNameFrom <> ""
        If GetAttr(PathNameFrom & DirNameFrom) = vbDirectory And DirNameFrom <> "." And DirNameFrom <> ".." Then
            PathNameTo = "W:\Absence Database\Absence_BE\To\"
            fso.CopyFolder PathNameFrom & DirNameFrom, PathNameTo & DirNameFrom, True
         End If
            DirNameFrom = Dir()
    Loop
End Sub

Hope that makes sense.

Thanks
 
afraid it doesn't

For example :
tmpFolder\123 to mainFolder\ABC_123

doesn't mean anything -
is that the partial match?
or what you want to find a partial match to?
and if the former which bit are you trying to match?
and is ABC_123 a folder name or a file name?

please provide some specific examples of what you mean by partial match
 
afraid it doesn't



doesn't mean anything -
is that the partial match?
or what you want to find a partial match to?
and if the former which bit are you trying to match?
and is ABC_123 a folder name or a file name?

please provide some specific examples of what you mean by partial match

Yes its is partial match. The matching part is from tmpFolder all name 123 in the mainFolder after "_" all rest string 123.

tmpFolder\123 to mainFolder\ABC_123
 

Users who are viewing this thread

Back
Top Bottom