Solved

copy fodlers adn subfolders to new namee

Posted on 2011-03-13
7
344 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this article we want to have a look at the directory attributes which are used by Microsoft to store the so called Security Identifiers (SID). These SIDs plays an important role in delegating and granting permissions and in authentication of trus…
I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

636 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