Cannot Perform a Cyclic Copy

I have a folder c:\data\_backup. I want to copy all of the files that are in data folder to _backup, then I created a script run.cmd in the folder _backup but I have no success, because it says:

Can not perform a cyclic copy
0 File (s) copied
Press any key to continue. . .

I use the following script:

cd..
xcopy ".\*" "%cd%\_backup\%date:~-4,4%-%date:~4,2%-%date:~7,2%" /s /i /y
pause
6

2 Answers

If you're only trying to copy files as your question states, robocopy will accomplish this without any options:

robocopy "c:\data" "c:\data\_backup"

By default robocopy only copies files, and there are plenty of options you can use if you're trying to accomplish other things or handle errors.

You can use robocopy to copy the files like mael' said above, with something like

set /P filea=What is the file you want to copy?
set /P fileb=Where do you want the file?
robocopy filea fileb
echo Copy done!
pause

If you want individual lines, you can do something like this

set /P filea=What is the file you want to copy?
set /P fileb=Where do you want the file?
%save%< %filea% (
set /p line1=
set /p line2=
set /p savedate=
)
set savedate=%DATE:~-4%%DATE:~4,2%%DATE:~7,2%%TIME%
(
echo %line1%
echo %line2%
echo %savedate%
) > %fileb%
echo Copy done!

To get individual lines, you'd need to put the same amount of echos that the file has in the first part, and only the lines you want in the second.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Elena Rostova

Elena Rostova

Lead Health, Wellness & Medical Journalist

Elena Rostova holds a Master's degree in Public Health Journalism. She covers groundbreaking medical research, holistic wellness trends, mental health awareness, and nutritional science.

Share this article
Twitter Facebook Pinterest