Batch file windows 7批处理文件以删除和删除文件夹,然后复制整个文件夹(及其子文件夹)
我已经很久没有创建任何批处理文件了 我要做的是删除整个文件夹,然后将另一个文件夹(及其子文件夹和文件)复制到我删除原始文件的位置(这是一个备份过程) 我遇到了三个问题:Batch file windows 7批处理文件以删除和删除文件夹,然后复制整个文件夹(及其子文件夹),batch-file,windows-7,copy,directory,Batch File,Windows 7,Copy,Directory,我已经很久没有创建任何批处理文件了 我要做的是删除整个文件夹,然后将另一个文件夹(及其子文件夹和文件)复制到我删除原始文件的位置(这是一个备份过程) 我遇到了三个问题: 批处理文件在运行删除操作时会提示我,这需要在“幕后”进行,因此不会提示我 del“c:\my folder location\myfoldertodelete”仅删除该文件夹中的文件 复制“c:\my other folder location\myother folder”“c:\my folder location\”仅复制
del“c:\my folder location\myfoldertodelete”
仅删除该文件夹中的文件复制“c:\my other folder location\myother folder”“c:\my folder location\”
仅复制该文件夹中的文件,而不复制子目录C:\Users\Chris>copy /s "C:\Users\Chris\Documents\Visual Studio 2010\Projects
\new project" "D:\VS 2010 projects\Projects\"
The syntax of the command is incorrect.
其中:
“C:\Users\user1\Documents\Src”是源目录和
“C:\Users\user1\Documents\Dest”是目标目录。ok越来越近,确实会删除整个目录,但副本不起作用。它说“命令的语法不正确”我刚刚用不起作用的命令更新了我的OP。我还尝试在目标中输入要复制的文件夹的名称,但这也不起作用。使用
xcopy
询问我以下问题并等待我的回答:C:\Users\user1\Documents\Dest是否在目标上指定文件名或目录名(F=file,D=directory)?输入D后,它恢复并完成工作。要查看此问题的解决方案,请参考我的解决方案。@ChristopherJohnson,您可能会得到“命令的语法不正确”,因为/s
与xcopy
一起,而不是copy
。
echo y | rd /s c:\directory.to.be.removed
copy /s c:\source c:\destination
echo y | rd /s C:\Users\user1\Documents\Dest
echo d | xcopy /s /y "C:\Users\user1\Documents\Src" "C:\Users\user1\Documents\Dest"