[英]copy directory and its contents without using xcopy or robocopy
xcopy
and robocopy
are not working when I try to transfer files to a remote drive, so i'm restricted to using del
and copy
until I can figure that out. 当我尝试将文件传输到远程驱动器时,
xcopy
和robocopy
无法正常工作,因此我只能使用del
和copy
直到我能弄清楚这一点。
Here is what I have so far: 这是我到目前为止的内容:
del /q y:\OPENcontrol\targetDir
for /d %%x in (y:\OPENcontrol\targetDir\*) do @rd /s /q "%%x"
copy c:\Users\CNC\share y:\OPENcontrol\targetDir
How can I copy folders and their contents without using xcopy
or robocopy
? 如何在不使用
xcopy
或robocopy
情况下复制文件夹及其内容?
Edit: This is on a CNC machine that is transferring files to its OPENcontrol module. 编辑:这是在将文件传输到其OPENcontrol模块的CNC机器上。 The code needs to work within the limitations of the OSAI controller.
该代码需要在OSAI控制器的限制内工作。 A good example is that
do (mkdir "destination\\%%i" copy "%%i\\*" "destination\\%%i")
had to execute in two separate loop commands, one for mkdir
and one for copy
一个很好的例子是
do (mkdir "destination\\%%i" copy "%%i\\*" "destination\\%%i")
必须在两个单独的循环命令中执行,一个用于mkdir
,另一个用于copy
As per my comment (not being 100% working at the time). 根据我的评论(当时不是100%正常工作)。 a Simple for loop will be able to run through each folder, create it and copy its contents.
一个简单的for循环将能够遍历每个文件夹,创建它并复制其内容。 There are better ways, but yes, you said you wanted to use
copy
specifically. 有更好的方法,但是是的,您说过要专门使用
copy
。 So as per your ammended comment: 因此,根据您的修改意见:
for /d /r "c:\Users\Nil\share" %%i in (*) do (
mkdir "c:\Users\Nil\targetDir\%%~nxi"
copy "%%i\*" "c:\Users\Nil\targetDir\%%~nxi"
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.