Windows cmd copy directories and content recursively if the files do not exist

1

The question fits in the title: I want to copy from local storage to a network storage directories and their content, but only the new or updated files with no prompt. My idea would be to use xcopy

xcopy source destination /s /e **only new or updated files**

user69453

Posted 2016-02-09T13:32:26.140

Reputation: 247

Answers

1

Windows cmd copy directories and content recursively if the files do not exist

My idea would be to use xcopy

Unfortunately XCOPY really doesn't do this by default very well if at all as far as copy ONLY what does not exist in the destination from the source. Also, XCOPY is deprecated per Microsoft and it's recommended to use the Robocopy command in place of it, and this especially makes sense to do if you're building a new process.

So while it's your idea to use XCOPY, I'm hopeful you'll be willing to use Robocopy for the particular need since it is a Windows native command line tool intended to replace XCOPY.


Robocopy Script Example

(Look over options to ensure all is set for your needs)

(Save below logic to a text file and rename to <something>.cmd and double-click to run as needed)

SET SRC="C:\path\source"
SET DEST="C:\path\destination"
SET FName=*.*
SET LOG=C:\Path\Log.txt
::   If you do not want a log file, remove the "/LOG+:%LOG%" below
SET OPT=/PURGE /S /NP /R:5 /LOG+:%Log% /TS /FP
SET CMD=robocopy %SRC% %FName% %DEST% %OPT%
%CMD%

Robocopy Copy and Paste Command Line Example

(Look over options to ensure all is set for your needs)

::   If you do not want a log file, remove the "/LOG+:C:\Path\Log.txt" below
robocopy "C:\path\source" *.* "C:\path\destination" /PURGE /S /NP /R:5 /LOG+:C:\Path\Log.txt /TS /FP

Further Resources and Reading

Pimp Juice IT

Posted 2016-02-09T13:32:26.140

Reputation: 29 425