Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

copy fodlers adn subfolders to new namee

Posted on 2011-03-13
7
Medium Priority
?
346 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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 2000 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This is an addendum to the following article: Acitve Directory based Outlook Signature (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_24950055.html) The script is fine, and works in normal client-server domains…
Well hello again!  Glad to see you've made it this far without giving up.  In this, the fourth installment of my popular series, I'm going to cover functions and subroutines, what they are, and why they are useful.  Just in case you stumbled onto th…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

704 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