将文件夹从一个网络位置复制到另一个网络的脚本

问题描述:

大家好,
我正在寻找可用于将网络文件夹从一个位置复制到另一位置的脚本.我目前正在进行迁移,该迁移将在我们的用户共享中以.V2格式创建一个文件夹,并且需要将文件/文件夹放置在此新位置,以使应用程序能够看到它们:

\\服务器\用户\用户的文件夹"

用户的文件夹"包含Profile&Profile.V2

我正在寻找的是一个脚本,可以在其中输入值(在本例中为用户名),以便它将在列表中运行以进行更改.

基本上,配置文件"目录中的所有内容都需要复制到"Profile.V2"中.

我正在考虑使用CSV来传递值,以便可以执行以下操作:

用户01
用户02
用户03

然后将脚本转到:

\\ server \ user \ User01 \ Profile

并将内容复制到

\\服务器\用户\ User01 \ Profile.V2

然后,我希望脚本继续执行02、03等操作...

如果有人有执行此操作的脚本,或者有任何建议/帮助,我将不胜感激!!!

谢谢,
Doug

Hey guys,
I''m looking for a script that i can use to copy network folders from one location to another. I am currently doing a migration which creates a folder inside our user share as a .V2, and needs the files/folders to be placed in this new location for the app to see them:

\\server\user\"user''s folder"

"User''s folder" contains Profile & Profile.V2

What I''m looking for is a script that i can pipe in values (in this case usernames) so it will run through the list making the changes.

Basically, everything from the "Profile" directory needs to be copied to "Profile.V2"

i was thinking about using a CSV to pipe in values so that i can do something like:

User 01
User 02
User 03

and then have the script go to:

\\server\user\User01\Profile

and copy the contents to

\\server\user\User01\Profile.V2

i would then like the script to continue on to 02, 03, ect...

If anyone has a script that would do this, or any suggestions/help I would really appreciate it!!!!

Thanks,
Doug

xcopy.exe绝对是您的朋友.它内置在Windows中,因此成本不高.我们还添加的一些选项包括:

•/s/e-递归副本,包括复制空目录.
•/v-添加此内容以对照原件验证副本.慢一点,但是偏执.
•/h-复制系统和隐藏文件.
•/k-复制只读属性以及文件.否则,所有文件都将变为可读写.
•/x-如果您关心权限,则可能需要/o或/x.
•/y-在覆盖现有文件之前不提示.
•/z-如果您认为副本可能会失败并且想要重新启动它,请使用此选项.它会在每个文件复制时在其上放置一个标记,因此您可以重新运行xcopy命令以从其停止的地方开始.

推荐的批处理脚本为:

xcopy.exe is definitely your friend here. It''s built into Windows, so it''s cost is nothing. some of the options we also add include these:

•/s/e - recursive copy, including copying empty directories.
•/v - add this to verify the copy against the original. slower, but for the paranoid.
•/h - copy system and hidden files.
•/k - copy read-only attributes along with files. otherwise, all files become read-write.
•/x - if you care about permissions, you might want /o or /x.
•/y - don''t prompt before overwriting existing files.
•/z - if you think the copy might fail and you want to restart it, use this. It places a marker on each file as it copies, so you can rerun the xcopy command to pick up from where it left off.

Recommended batch script is:

xcopy /s/z sourcefolder targetfolder


感谢您的快速响应.我当时在考虑使用xcopy或robocopy,但是我唯一遇到的问题就是自动化.我大约有500个用户需要复制如上所述的文件.与此相关的另一个问题是,他们必须已经登录到新环境,该新环境反过来又创建了Profile.V2文件夹.

我对此的想法是:

-build某种错误捕获,脚本在其中检查.V2文件夹.如果在其中运行副本,或者不运行副本,则可能会列出文件夹名称

-让脚本从CSV列表中运行,在这里我可以手动输入用户帐户并以这种方式运行.

有想法吗?
Thanks for the quick response. I was thinking on using xcopy or robocopy, but the only issue i have with either is automation. I have around 500 users that need to have files copied as mentioned above. Another catch with this is that they must have already logged into the new environment which in turn creates the Profile.V2 folder.

My thoughts on this were either to:

-build in some kind of error catch where the script checks for the .V2 folder. If there run the copy, and if not skip the copy and maybe list the folder name

-have the script run off of a CSV list where i can manually enter the user accounts and have it run that way.

Thoughts?