I have a batch file that copies any new, updated files to an external drive.
In one source folder, I moved quite a few files around. These files will copy but then there will be a copy in the original destination location.
Is there a way that DOS when copying to the destination folder, delete files it did not find in the source?
Thanks in advance.
Replicate files and folders to external drive with copy command
Moderator: DosItHelp
Re: Replicate files and folders to external drive with copy command
Would be really helpful if you showed us the code you are using. I am going to assume you are not using ROBOCOPY because I believe it has the functionality you are looking for.
Re: Replicate files and folders to external drive with copy command
Example of my current batch file
xcopy "c:\users\test\test" "e:\test" /s /e /d /y /v
Is there a switch or another DOS command, so that the files that are new, modified gets copied. File not on source but in the destination folder gets deleted from the destination folder?
xcopy "c:\users\test\test" "e:\test" /s /e /d /y /v
Is there a switch or another DOS command, so that the files that are new, modified gets copied. File not on source but in the destination folder gets deleted from the destination folder?
Re: Replicate files and folders to external drive with copy command
falcios wrote:Is there a switch or another DOS command, so that the files that are new, modified gets copied. File not on source but in the destination folder gets deleted from the destination folder?
Squashman wrote:I am going to assume you are not using ROBOCOPY because I believe it has the functionality you are looking for.
Robocopy Help
Code: Select all
/MIR :: MIRror a directory tree (equivalent to /E plus /PURGE).
/E :: copy subdirectories, including Empty ones.
/PURGE :: delete dest files/dirs that no longer exist in source.
Re: Replicate files and folders to external drive with copy command
Thanks so much. It is exactly what I am looking for and it works great.