Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
912 views
in Technique[技术] by (71.8m points)

batch-file - 批处理文件将文件从一个文件夹复制到另一个文件夹(Batch file to copy files from one folder to another folder)

I have a storage folder on a network in which all users will store their active data on a server.

(我在网络上有一个存储文件夹,所有用户都将其活动数据存储在服务器上。)

Now that server is going to be replaced by a new one due to place problem so I need to copy sub folders files from the old server storage folder to new server storage folder.

(现在由于地方问题,服务器将被新服务器替换,因此我需要将子文件夹文件从旧服务器存储文件夹复制到新服务器存储文件夹。)

I have below ex:

(我有以下ex:)

from \Oldeserver\storage\data & files to \New server\storage\data & files.

(从\ Oldeserver \ storage \ data&files到\ New server \ storage \ data&files。)

  ask by user73628 translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

xcopy.exe is definitely your friend here.

(xcopy.exe绝对是你的朋友。)

It's built into Windows, so its cost is nothing.

(它内置于Windows中,因此它的成本一无所获。)

Just xcopy /sc:\source d:\target

(只需xcopy /sc:\source d:\target)

You'd probably want to tweak a few things;

(你可能想要调整一些东西;)

some of the options we also add include these:

(我们还添加了一些选项包括:)

  • /s/e - recursive copy, including copying empty directories.

    (/s/e - 递归复制,包括复制空目录。)

  • /v - add this to verify the copy against the original.

    (/v - 添加此项以验证原始副本。)

    slower, but for the paranoid.

    (较慢,但对于偏执狂。)

  • /h - copy system and hidden files.

    (/h - 复制系统和隐藏文件。)

  • /k - copy read-only attributes along with files.

    (/k - 将只读属性与文件一起复制。)

    otherwise, all files become read-write.

    (否则,所有文件都变为读写。)

  • /x - if you care about permissions, you might want /o or /x .

    (/x - 如果您关心权限,则可能需要/o/x 。)

  • /y - don't prompt before overwriting existing files.

    (/y - 在覆盖现有文件之前不要提示。)

  • /z - if you think the copy might fail and you want to restart it, use this.

    (/z - 如果您认为副本可能会失败并且您想要重新启动它,请使用此方法。)

    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.

    (它在复制时在每个文件上放置一个标记,因此您可以重新运行xcopy命令以从中断的位置进行拾取。)

If you think the xcopy might fail partway through (like when you are copying over a flaky network connection), or that you have to stop it and want to continue it later, you can use xcopy /s/zc:\source d:\target .

(如果您认为xcopy可能在中途失败(例如,当您通过片状网络连接进行复制时),或者您必须停止它并希望以后继续它,则可以使用xcopy /s/zc:\source d:\target 。)

Hope this helps.

(希望这可以帮助。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...