简体   繁体   English

使用批处理文件复制文件...窗口

[英]copying files using a batch file…windows

I have a file copyfiles.bat and i want to do the following inside of my batch file: 我有一个文件copyfiles.bat,我想在我的批处理文件中执行以下操作:

 copy "C:\temp\file1.txt" "c:\users\me\my directory"
 copy "C:\temp\dir2\file2.txt" "c:\users\me\my directory\dir2"

I save and run the batch file and nothing is being copied. 我保存并运行批处理文件,没有任何东西被复制。 All files and directories exist. 存在所有文件和目录。 What am I doing wrong? 我究竟做错了什么? Thanks 谢谢

Try xcopy command instead of copy. 尝试xcopy命令而不是复制。 Here is official docs about it 是关于它的官方文档

Give file name for destination path also like below 为目标路径提供文件名,如下所示

copy "C:\\temp\\file1.txt" "c:\\users\\me\\my directory\\file1.txt" 复制“C:\\ temp \\ file1.txt”“c:\\ users \\ me \\ my directory \\ file1.txt”

Sometimes directory names with space in between will also cause issue.I faced such an issue once. 有时候,其间有空格的目录名也会引起问题。我曾经遇到过这样的问题。 Please check with directory names without space in between. 请检查目录名称,两者之间没有空格。

To replace the existing file /Y option is also required, which will suppress the prompt for asking whether you want to replace. 还需要替换现有文件/ Y选项,这将禁止询问您是否要替换。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM