Solved

copy fodlers adn subfolders to new namee

Posted on 2011-03-13
7
294 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Welcome, welcome!  If you are new to the series and haven't been following along, please take a brief moment to review the first three installments: Part 1 (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/A_266-VBScri…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now