且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

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

更新时间:2023-11-27 22:04:40

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?