Move files and subfolders from one folder to another (1 Viewer)

guestbb

Registered User.
Local time
Today, 01:31
Joined
Jul 14, 2015
Messages
44
So what I want is to move (or copy then kill the files on the old location) all of the all of files and subfolders (if there are any) from one folder to another.
I have made it to move files but not subfolders. Does anyone have solution for making it move/copy subfolders?

Code:
Dim OldPath As String
Dim NewPath As String
Dim FnameAs String

Fname = Dir(OldPath & "*.*")
    Do While Fname <> ""
        Name OldPath & Fname As NewPath & Fname
        Fname = Dir
    Loop
 

guestbb

Registered User.
Local time
Today, 01:31
Joined
Jul 14, 2015
Messages
44
I google all of that but it isnt what I need.
It needs to check automatically for all files and subfolders, grab their name and then move them.
On all of the code I could find its the person that is typing the subfolder names and that is not what I want. If I have a subfolder I want the code to get is name then move it to a new location.
 

guestbb

Registered User.
Local time
Today, 01:31
Joined
Jul 14, 2015
Messages
44
Solved

Code:
Fname = Dir(OldPath & "*.*")
    Do While Fname <> ""
        Name OldPath & Fname As NewPath & Fname
        Fname = Dir
    Loop
    
    Set FSO = CreateObject("Scripting.FileSystemObject")
    FSO.CopyFolder OldPath, NewPath, True
    Set FSO = Nothing
 
Last edited:

Users who are viewing this thread

Top Bottom