?
Solved

script to copy a file from one location to another

Posted on 2007-10-12
8
Medium Priority
?
1,717 Views
Last Modified: 2008-02-01
I have pst files in user folders that I need to move to another shared area on the same server. I need a vbs/cmd/batch file to run this.
The folder structure is as follows:
\\server1\userarchive\user initials\notes_user initials.pst and I need it to go to \\server1\userdata\user initials\_notes archive
There are a few hundred users that this will need to go through.
There is only one .pst file in each user folder so *.pst will be fine in the script

Please help, very urgent

Steve
0
Comment
Question by:shconsultancy
8 Comments
 
LVL 2

Expert Comment

by:Kragster
ID: 20065177
For clarification given a example user with initials "abc"
you would have:
\\server1\userarchive\abc\notes_abc.pst
and want it to become
\\server1\userdata\abc\_notes archive\notes_abc.pst

is that right?
0
 
LVL 1

Author Comment

by:shconsultancy
ID: 20065227
Yes that is correct
0
 
LVL 12

Expert Comment

by:chandru_sol
ID: 20065244
Hi,
Yes you can use it to copy to network drives

Robocopy is a microsoft tool which many IT adminsitrators use to copy

http://www.ss64.com/nt/robocopy.html

The above link will give you a good start.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Author Comment

by:shconsultancy
ID: 20065341
Yes but will Robocopy loop through all of the hundreds of user folders to do what I ask it to?
0
 
LVL 2

Accepted Solution

by:
Kragster earned 2000 total points
ID: 20065522
The following is not pretty, but will work.  It will do every folder underneath the user archive folder so if there are any non user initial folders it will try to copy them too.  

On Error Resume Next
Dim objFSO, objSourceFolder, objDestFolder

Dim Source, Dest
Source = "\\server1\userarchive\"
Dest = "\\server1\userdata\"

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objSourceFolder = objFSO.GetFolder(Source)

Dim userInitials, objSubFolder, objFile, tempSource, tempDest

For Each objSubFolder in objSourceFolder.SubFolders
      userInitials = objSubFolder.Name
      tempSource = Source & userInitials & "\notes_" & userInitials & ".pst"
      tempDest = Dest & userInitials & "\_notes archive\notes_" & userInitials & ".pst"
      Set objDestFolder = objFSO.GetFolder(Dest & userInitials)
      objFSO.CopyFile tempSource, tempDest
Next
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 20065724
copy \\server1\userarchive\%USERNAME%\notes_user initials.pst  \\server1\userdata\%USERNAME%\_notes archive\

:# is this what you mean?
0
 
LVL 2

Expert Comment

by:Kragster
ID: 20065832
One problem with my solution I just noticed is that it copies and you said move.  You can change the line that says....

objFSO.CopyFile tempSource, tempDest
to
objFSO.MoveFile tempSource, tempDest

0
 
LVL 1

Author Comment

by:shconsultancy
ID: 20065875
Excellent, just what I was looking for. I managed to change the Copy to Move before you sent the message.

Superb service

Steve
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Suggested Courses
Course of the Month17 days, 10 hours left to enroll

830 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