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.
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
?
Edit: This is on a CNC machine that is transferring files to its OPENcontrol module. The code needs to work within the limitations of the OSAI controller. 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
As per my comment (not being 100% working at the time). a Simple for loop will be able to run through each folder, create it and copy its contents. There are better ways, but yes, you said you wanted to use copy
specifically. 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"
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.