Copy only new files using Robocopy

Microsoft Windows
Post Reply
User avatar
MigrationUser
Posts: 336
Joined: 2021-Jul-12, 1:37 pm
Contact:

Copy only new files using Robocopy

Post by MigrationUser »

22 Feb 2008 19:39
Greg

I want to use Robocopy to copy files from my 2nd HD to my external USB HD. I previously copied the entire 2nd HD to the USB drive but now I want to copy to the external drive, only those files that have been changed or added to the 2nd drive.

Can someone tell me what switches would accomplish this using Robocopy?

Thanks,

Greg

----------------------------

#2 26 Feb 2008 10:21
Simon Sheppard


What you are looking for is actually the default behaviour

https://ss64.com/nt/robocopy.html
" By default Robocopy will only copy a file if the source and destination have different time stamps or different file sizes."
If a source file is edited to a newer (or older) date/time, then robocopy will write it to the destination.

The best thing is to grab a few sample files and test the behaviour before running the command against thousands of files.

----------------------------

#3 26 Feb 2008 20:37
Greg


Simon, I made a .bat file to run this but I'm getting "invalid parameter #4" from the robocopy script and it won't write a log file
.
Here's is what's contained in the .bat file:

Code: Select all

Robocopy "D:\" "G:\GCH Backup\From D Drive" /S /NP /XF Pagefile.sys /XD "My
Documents" "System Volume Information" "Recycler" "Temporary Internet Files"
/LOG:"D:\Backup Stuff\Batch\D_Backup.log"
Although the error is showing up from Robocopy GUI (saved script) which I only used to mimick my .bat file to get an output. Looks to show the source and destination as the same.(???)

Source - D:\" G:\GCH\
Dest - D:\Backup\From\

Files : D

Options : /COPY:DAT /R:1000000 /W:30

ERROR : Invalid Parameter #4 : "Drive /S /NP /LOG:Backup"

Appreciate anything you can tell me. I'm using robocopy to copy My Documents from the C: drive to my USB drive with no problems. Can't figure out why copying from my 2nd drive to the USB is not functioning.

Thanks,
Greg

----------------------------

#4 27 Feb 2008 11:31
Simon Sheppard


I think your problem is that robocopy uses the backslash '\' to escape certain characters including double quotes

This means that "D:\" gets interpreted as D:\" instead of D:\

So Robocopy is reading [%1] as [D:\" G:\GCH\] not only is that completely invalid but with the quote marks out-of-sync it then proceeds to get confused about what all the other parameters are.

Try just using D:\ without any quotes

----------------------------

#5 27 Feb 2008 13:12
bluesxman
Simon Sheppard wrote:

Try just using D:\ without any quotes
"D:\\" should work too...

cmd | *sh | ruby | chef

----------------------------

#6 29 Feb 2008 01:25
Greg


Thanks guys, that was exactly the problem.

Greg

----------------------------

#7 13 Mar 2011 17:02
henrin


I had the same problem and looked for a solution that should work when specifying a drive or a directory.
The one I have found is to add a blank character before the leading double quote:

directory name for Robocopy = '\"' + directory name + ' "\'

(allowing blank characters in file names was a false good idea!)

----------------------------

#8 14 Mar 2011 21:09
bluesxman


I think you mean adding a space before the trailing double quote, thus:

Code: Select all

robocopy "c:\ " "d:\ "
Which does seem to work (who knew?), but I prefer the "." method:

Code: Select all

robocopy "c:\." "d:\."
cmd | *sh | ruby | chef
Post Reply