我在网络上有一个存储文件夹,所有用户将在服务器上存储他们的活动数据。现在,由于位置问题,服务器将被一个新的服务器所取代,所以我需要将子文件夹文件从旧的服务器存储文件夹复制到新的服务器存储文件夹。我有以下例子:
从\Oldeserver\存储\数据和文件到\新服务器\存储\数据和文件。
我在网络上有一个存储文件夹,所有用户将在服务器上存储他们的活动数据。现在,由于位置问题,服务器将被一个新的服务器所取代,所以我需要将子文件夹文件从旧的服务器存储文件夹复制到新的服务器存储文件夹。我有以下例子:
从\Oldeserver\存储\数据和文件到\新服务器\存储\数据和文件。
当前回答
Xcopy.exe绝对是你的朋友。 它内置在Windows中,所以它的成本是零。
xcopy /s c:\source d:\target
你可能想要调整一些东西;我们还添加了以下选项:
/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.
如果你认为xcopy可能会中途失败(比如当你在一个脆弱的网络连接上复制时),或者你必须停止它并想稍后继续它,你可以使用xcopy /s/z c:\source d:\target。
其他回答
Windows用户
创建copyfile.bat
#!AutoCopy
xcopy /s C:\folder\from C:\folder\to
打开cmd 输入copyfile.bat按enter键
你可能想看看XCopy或RoboCopy,它们是非常全面的解决方案,几乎适用于Windows上的所有文件复制操作。
@echo off
rem The * at the end of the destination file is to avoid File/Directory Internal Question.
rem You can do this for each especific file. (Make sure you already have permissions to the path)
xcopy /Y "\\Oldeserver\storage\data\MyFile01.txt" "\\New server\storage\data\MyFile01.txt"*
pause
rem You can use "copy" instead of "xcopy "for this example.
看看基于rsync的Windows工具NASBackup。如果您熟悉rsync命令,这将是一个额外的奖励。
Xcopy.exe绝对是你的朋友。 它内置在Windows中,所以它的成本是零。
xcopy /s c:\source d:\target
你可能想要调整一些东西;我们还添加了以下选项:
/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.
如果你认为xcopy可能会中途失败(比如当你在一个脆弱的网络连接上复制时),或者你必须停止它并想稍后继续它,你可以使用xcopy /s/z c:\source d:\target。