Link to home
Start Free TrialLog in
Avatar of Darrell Kirby
Darrell KirbyFlag for United States of America

asked on

Script or Batch File for Copying

I am moving a variety of files(PST) located in separate directories. They are being moved from the users current directory to a new directory structure. Is there a command that can be used in a script or batch file to move these? Example SJones to USR019499 (New User Account). I also want to retain the rights. I have to do this with 1000 users. I know Robocopy is one way to possible do this.
Avatar of morganmce
morganmce
Flag of Ireland image

Hi jimlancioni,

Just to make sure I'm understanding the requirements correctly:
You currently have all the PSTs on a server in a directory with the username (E.g. C:\data\userid
You now want to copy the move the files to another path (E.g. F:\data\newuserid) and keep the currently assigned permissions?

You currently have full control over the folders in their current location

Are those assumptions correct? There are a few ways of doing this, but I just wanted to check I'm understanding your requirements correctly.

Are the NTFS permissions changing (you suggest that a different user account will be used after the process is complete).

Thanks
Avatar of Darrell Kirby

ASKER

That is correct. We are moving from one location on the same volume to different directories. We are going from Username to a new User ID. Manual copying would be a lot of work. I have full admin rights and the NTFS permissions are not changing.

Thanks.
Perfect. Are do you have a list of the current & future user IDs in a file or elsewhere?

(e.g. SJones to USR019499 as you mentioned)
Yes I do. They are currently in an Excel spreadsheet.
ASKER CERTIFIED SOLUTION
Avatar of morganmce
morganmce
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This script pretty much sets the folder name?
Yes, maybe I misunderstood, but my understanding is that you want to copy all the user folders from volume A to volume B, but changing the folder name as the username will be changing.

i.e. C:\userdata\SJones will in future have the data on F:\userdata\USR019499
The xcopy will copy the data and the VBS will rename the folder to have the correct folder name based on what it reads from the CSV file.

On re-reading, is it that you want to segregate PSTs from the mix - i.e. that you will be leaving the other data behind?
That is correct. The other data will be left behind for now. We are separating the backup PST's from the current users directory. The second step is to copy the old directory to the new directory.
Does anything have to be changed in the following line of script for my envirnment?  
       
        oldUser = arrStr(0)
      newUser = arrStr(1)
      srcFolder = path & oldUser
      TargetFolder = path & newUser

Thank you.
Hi  jimlancioni,

Re your latest comment, there should be no need to modify those lines - the assumption of the script is that the data is already coped and that the rename will be based on the values read in from the CSV file.
Assuming the CSV file contains the following, on the first iteration of the loop, it will rename the SJones folder to USR019499, on  the second iteration it will rename the BMurphy folder to USR19500.

SJones,USR019499
BMurphy,USR19500

Open in new window


The only part that needs to be set to match your environment is line 8 - the path the folders are located in:
path = "C:\test\users\"

(I would suggest as a test to create a shorter CSV with a few sample users)

I'll have a look at something to leave behind non-pst files shortly.
Let me know if you have any other questions!
Correct. I'm Moving PST's from the old directory to a separate Volume that currently includes the UserID.
This gave me a good start for what I wanted to accomplish.