copy fodlers adn subfolders to new namee

I need a scriipt to do the following:

Under O:\Users\Homedirs there's a list of subfolder starting with PSR???? and under PSR????  there's a subfolder called Notes and under Notes there's a folder called Data.

Example
Rename O:\Users\Homedirs\psr101a\notes\data to O:\Users\Homedirs\psr101a\notes\mgrdata
Rename O:\Users\Homedirs\psr255a\notes\data to O:\Users\Homedirs\psr101a\notes\mgrdata
Rename O:\Users\Homedirs\psr650a\notes\data to O:\Users\Homedirs\psr101a\notes\mgrdata


and so on
Bianchi928Asked:
Who is Participating?
 
prashanthdConnect With a Mentor Commented:
Try the following
on error resume next
Set objFSO = CreateObject("Scripting.FileSystemObject")
objStartFolder = "O:\Users\Homedirs\"

Set objparent = objFSO.GetFolder(objStartFolder)

For Each Subfolder In objparent.SubFolders
    WScript.Echo Subfolder.Path
    Set objFolder = objFSO.GetFolder(Subfolder.Path)
    If InStr(LCase(objfolder.Name),"psr")>0 Then
        psrfolder=Replace("o:\users\homedirs\psrfolder\notes\data","psrfolder",LCase(objfolder.Name))
        renfolder=Replace(psrfolder,"\data","\mgrdata")
        'WScript.Echo psrfolder & renfolder
        If objfso.FolderExists(psrfolder) Then
            objfso.CopyFolder psrfolder , renfolder
            WScript.Echo "Copied - " & psrfolder & " to - " & renfolder
        End If
    End If
Next

Open in new window

0
 
Bianchi928Author Commented:
I forgot to attached a input file which can be used as a reference and also,,iI want to COPY ,not RENAME as previously stated

Thanks
Cheers
0
 
Bianchi928Author Commented:
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
prashanthdCommented:
Copy files or folder? Still not clear..
0
 
ajn_auCommented:
You could do this simply with a batch file rather than VB Script.  Have a look at the "FOR" command at the Microsoft reference link <http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/batch.mspx?mfr=true
0
 
Bianchi928Author Commented:
I have specific reasons why I need a VBScript. I already know how to do it with a batch file.

Thanks
0
 
Bianchi928Author Commented:
All good
Thanks
0
All Courses

From novice to tech pro — start learning today.