Solved

copy fodlers adn subfolders to new namee

Posted on 2011-03-13
7
316 Views
Last Modified: 2012-05-11
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
0
Comment
Question by:Bianchi928
  • 4
  • 2
7 Comments
 

Author Comment

by:Bianchi928
ID: 35121136
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
 

Author Comment

by:Bianchi928
ID: 35121138
0
 
LVL 12

Expert Comment

by:prashanthd
ID: 35121147
Copy files or folder? Still not clear..
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 1

Expert Comment

by:ajn_au
ID: 35121177
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
 

Author Comment

by:Bianchi928
ID: 35123189
I have specific reasons why I need a VBScript. I already know how to do it with a batch file.

Thanks
0
 
LVL 12

Accepted Solution

by:
prashanthd earned 500 total points
ID: 35124451
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
 

Author Closing Comment

by:Bianchi928
ID: 35125957
All good
Thanks
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Script to copy or move mouse-selected collection of files plus targets referenced by shortcuts (.lnk) The purpose of this article is to help illuminate the real challenges and options available (where they may exist) for utilizing simple scriptin…
When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question