Go Back   Access World Forums > Microsoft Access Discussion > Modules & VBA

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 07-16-2019, 02:06 AM   #1
Juolupuki
Newly Registered User
 
Join Date: Jan 2018
Posts: 31
Thanks: 23
Thanked 0 Times in 0 Posts
Juolupuki is on a distinguished road
Check folder name and copy

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

Juolupuki is offline   Reply With Quote
Old 07-16-2019, 04:04 AM   #2
CJ_London
Super Moderator
 
Join Date: Feb 2013
Location: UK
Posts: 10,998
Thanks: 40
Thanked 3,573 Times in 3,452 Posts
CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light
Re: Check folder name and copy

afraid it doesn't

Quote:
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
__________________
CJ_London
_______________________
A little thanks goes a long way. If you have found this post useful, please tick the thanks button
CJ_London is offline   Reply With Quote
Old 07-16-2019, 04:54 AM   #3
Juolupuki
Newly Registered User
 
Join Date: Jan 2018
Posts: 31
Thanks: 23
Thanked 0 Times in 0 Posts
Juolupuki is on a distinguished road
Re: Check folder name and copy

Quote:
Originally Posted by CJ_London View Post
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

Juolupuki is offline   Reply With Quote
Old 07-16-2019, 05:02 AM   #4
CJ_London
Super Moderator
 
Join Date: Feb 2013
Location: UK
Posts: 10,998
Thanks: 40
Thanked 3,573 Times in 3,452 Posts
CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light
Re: Check folder name and copy

still confused

provide some examples

__________________
CJ_London
_______________________
A little thanks goes a long way. If you have found this post useful, please tick the thanks button
CJ_London is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
VBScript copy file to folder then cut it and past it in another folder Alhakeem1977 Visual Basic 7 06-24-2019 03:30 AM
Copy folder Super Suarez General 1 07-17-2013 07:12 AM
Copy from A Drive to a folder frankbutcher Forms 3 02-27-2006 11:35 AM
Folder Copy StuBailey Modules & VBA 7 01-17-2003 07:26 AM
Copy folder Philmore Modules & VBA 2 03-16-2002 02:46 PM




All times are GMT -8. The time now is 07:41 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World