Excluding a sub directory when using movefolder in VB script

I am trying to write a script to move all of the sub directories in a folder except one subdirectory using the FSO movefolder?
LDickeAsked:
Who is Participating?
 
Shift-3Connect With a Mentor Commented:
Paste the script below into a text file with a .vbs extension.  Customize the value of the strSource variable with the location of the source folder.  Customize the value of the strDest variable with the location of the destination folder.  Customize the value of the strExclude variable with the name of the subfolder to exclude.  Running the script will move all subfolders except the specified one.


strSource = "c:\source folder"
strDest = "c:\destination folder"
strExclude = "excluded folder"
 
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objSource = objFSO.GetFolder(strSource)
 
For Each objChild in objSource.Subfolders
    If Not LCase(objChild.Name) = LCase(strExclude) Then
        objFSO.MoveFolder objChild.Path, strDest & "\"
    End If
Next

Open in new window

0
 
LDickeAuthor Commented:
Thank You

that was perfect.
0
 
LDickeAuthor Commented:
Thank You
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.