I have checked some examples on internet but I can't get my (first) batch file to work. I would like to copy automatically my file from a folder to another one but nothing happen.
我在网上查了一些例子,但是我不能让我的(第一个)批处理文件工作。我想把我的文件从文件夹自动复制到另一个文件夹,但是什么也没有发生。
@echo off
xcopy "C:\source\" "C:\target\" /c /d /i /y
exit
Could you see anything wrong?
你看错了吗?
Thanks!!
谢谢! !
Update: I have done the command given by Bali C but it still doesn't work. See snapshot
更新:我已经完成了巴厘C的命令,但是仍然没有效果。看到快照
xcopy C:\folder1 C:\folder2\folder1 /t /e /i /y
xcopy C:\folder1 C:\folder2\ /t /e /i /y
图片:
I have to stop it with CTRL + C.
我必须用CTRL + C停止。
PS: I'm on Win 7
我赢了。
Update (Solution): It works! The problem was the name xcopy,bat on my Desktop, and I was running the command from there, so it was executing the xcopy.bat file of my desktop instead of the Windows one.. I had to rename the file with "myxcopy.bat" :
更新(解决方案):它的工作原理!问题是xcopy,bat在我的桌面上,我正在运行这个命令,所以它在执行xcopy。我的桌面的bat文件,而不是Windows的。我必须用“myxcopy”重命名文件。蝙蝠”:
@echo off
xcopy "C:\source" "C:\target" /c /d /i /y
exit
4 个解决方案
#1
6
After testing most of the switches this worked for me:
在测试了大多数开关后,这对我起了作用:
xcopy C:\folder1 C:\folder2\folder1 /t /e /i /y
This will copy the folder folder1
into the folder folder2
. So the directory tree would look like:
这将把文件夹folder1复制到文件夹folder2中。目录树是这样的
C:
Folder1
Folder2
Folder1
#2
4
Based on xcopy help, I tried and found that following works perfectly for me (tried on Win 7)
在xcopy的帮助下,我尝试了一下,并发现下面的方法对我来说是完美的(尝试了Win 7)
xcopy C:\folder1 C:\folder2\folder1 /E /C /I /Q /G /H /R /K /Y /Z /J
#3
1
You must specify your file in the copy:
您必须在副本中指定您的文件:
xcopy C:\source\myfile.txt C:\target
Or if you want to copy all txt files for example
或者如果你想复制所有的txt文件。
xcopy C:\source\*.txt C:\target
#4
1
If the requirement is to copy all files in "\Publish\Appfolder" into the parent "\Publish\" folder (inclusive of any subfolders, following works for me) The switch '/s' allows copying of all subfolders, recursively.
如果要求是将“\Publish\Appfolder”中的所有文件复制到父“\发布\”文件夹(包含任何子文件夹,下面的工作为我工作),开关'/s'可以递归地复制所有子文件夹。
xcopy src\main\Publish\Appfolder\*.* /s src\main\Publish\
选择复制文件主要src \ \发布\ Appfolder \ *。* / s src \主要\ \发布
#1
6
After testing most of the switches this worked for me:
在测试了大多数开关后,这对我起了作用:
xcopy C:\folder1 C:\folder2\folder1 /t /e /i /y
This will copy the folder folder1
into the folder folder2
. So the directory tree would look like:
这将把文件夹folder1复制到文件夹folder2中。目录树是这样的
C:
Folder1
Folder2
Folder1
#2
4
Based on xcopy help, I tried and found that following works perfectly for me (tried on Win 7)
在xcopy的帮助下,我尝试了一下,并发现下面的方法对我来说是完美的(尝试了Win 7)
xcopy C:\folder1 C:\folder2\folder1 /E /C /I /Q /G /H /R /K /Y /Z /J
#3
1
You must specify your file in the copy:
您必须在副本中指定您的文件:
xcopy C:\source\myfile.txt C:\target
Or if you want to copy all txt files for example
或者如果你想复制所有的txt文件。
xcopy C:\source\*.txt C:\target
#4
1
If the requirement is to copy all files in "\Publish\Appfolder" into the parent "\Publish\" folder (inclusive of any subfolders, following works for me) The switch '/s' allows copying of all subfolders, recursively.
如果要求是将“\Publish\Appfolder”中的所有文件复制到父“\发布\”文件夹(包含任何子文件夹,下面的工作为我工作),开关'/s'可以递归地复制所有子文件夹。
xcopy src\main\Publish\Appfolder\*.* /s src\main\Publish\
选择复制文件主要src \ \发布\ Appfolder \ *。* / s src \主要\ \发布