DemonWareXT
DemonWareXT

Reputation: 531

Move Folder into different Folder with VBS

I've been trying to make a little VBS that gets all Home Directories on a Server and moves them to a different place. Little Example

C:\homefolders\test_person C:\homefolders\test_person\old_home

Here is what I got so far, but the moving part doesn't work...

Call ListFolderContents("C:\Windows\System32\Drivers")

Sub ListFolderContents(path)
    set fs = CreateObject("Scripting.FileSystemObject")
    set folder = fs.GetFolder(path)
    Msgbox folder.path

    For each item in folder.SubFolders
        ListFolderContents(item.Path)
    Next
    set folder = Nothing
    set fs = Nothing
End Sub

Upvotes: 2

Views: 15479

Answers (1)

Mario Vernari
Mario Vernari

Reputation: 7306

Assuming there's no problem with permissions:

set fs = CreateObject("Scripting.FileSystemObject")
set folder = fs.GetFolder(path)
folder.Move newPath

Cheers

Upvotes: 6

Related Questions