Windows 7批处理文件删除和删除文件夹,然后复制整个文件夹(和子文件夹)
我已经很长时间没有创建任何批处理文件了。
我想要做的是删除整个文件夹,然后将另一个文件夹(及其子文件夹和文件)复制到我删除原始文件的位置(这是一个备份过程)。
我遇到了三个问题:
- 批处理文件在运行删除操作时提示我,而这需要在“幕后”发生,因此无法提示我。
del "c:\我的文件夹位置\myfoldertolete"
仅删除该文件夹中的文件copy "c:\我的其他文件夹位置\myotherfolder" "c:\我的文件夹位置\ "
仅复制该文件夹中的文件,而不复制子目录。
我想我需要 xcopy 或其他东西,但我从未使用过。如果有人能帮助我跨越这三个障碍,我将不胜感激。
编辑:(使用不起作用的复制命令进行更新
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.
It's been a long time since I've created any batch files.
What I'm trying to do is delete an entire folder, and then copy another folder (and it's sub folders and files) to the location where I deleted the original file (this is a backup process).
I've run into three problems:
- the batch file prompts me when it runs the delete operation and this needs to happen "behind the scenes" so I can't be prompted.
- the
del "c:\my folder location\myfoldertodelete"
only deletes the files within that folder - the
copy "c:\my other folder location\myotherfolder" "c:\my folder location\"
only copies the files within that folder, not the sub directories.
I assume I need xcopy or something but I've never used that. If anyone can help me jump through these three hoops, I'd greatly appreciate it.
edit: (updating with the copy command that isn't working
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在哪里:
“C:\Users\user1\Documents\Src”是源目录,
“C:\Users\user1\Documents\Dest”是目标目录。
where:
"C:\Users\user1\Documents\Src" is the Source directory and
"C:\Users\user1\Documents\Dest" is the Destination directory.