I want to COPY and REPLACE files from one folder to another, but I cant seem to get it to work

copy D:\FolderPath\Pictures\test.txt C:\Users\FolderPath\Desktop\test\test*.txt pause 

Any help would be much appreciated.

2 Answers

For your immediate concern, you want to move that wildcard to your source, not your destination, and just list the target directory as your destination. Also, tack a "/Y" option on the end to automatically overwrite files in the destination. So something like this should work:

copy D:\FolderPath\Pictures\test*.txt C:\Users\FolderPath\Desktop\test /Y 

If you are copying entire directories, then you might want to step up to ROBOCOPY as it has a great many options that can handle most any situation you can imagine, including overwriting, not overwriting, not adding new files, and purging old files when new ones are absent. You can read more about it here.

2

To copy while changing the name from test1.txt to test.txt, do:

copy D:\FolderPath\Pictures\test1.txt C:\Users\FolderPath\Desktop\test\test.txt 

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy