4

I have this code:

@echo on
set source="R:\Contracts\"
set destination="R:\Contracts\Sites"

::Not sure if this is needed
::It guarantees you have a canonical path (standard form)
for %%F in (%destination%) do set destination="%%~fF"

for /r %source% %%F in (.) do if "%%~fF" neq %destination% ROBOCOPY "%%F" %destination% *.srt *.pdf *.mp4 *.jpg /COPYALL /R:0

Pause

I am not sure if the code above has "SKIP commands" if file exists / or skip if file is the same size?

ΩmegaMan
  • 29,542
  • 12
  • 100
  • 122
Arthor
  • 666
  • 2
  • 13
  • 40

2 Answers2

8

Do you want to exclude files of the same size, or files that haven't changed? If it's the latter, use the /XO switch in RoboCopy to exclude files that are older than those they're being copied over.

RoboCopy "%%F" %destination% *.srt *.pdf *.mp4 *.jpg /COPYALL /XO /R:0
Hand-E-Food
  • 12,368
  • 8
  • 45
  • 80
  • Hello, I want to exclude all files that have not changed. I have checked the the summary and it shows 0 files skipped and 135 files as extras. I am not sure what extras are. – Arthor Jan 20 '12 at 14:24
  • 1
    It means you have 135 files in the destination folder that don't exist in the source folder. It's an indication that you may need to clean them up. You can use the `/PURGE` switch to clean out these extra files each time. Be careful because they are permanently deleted, not moved to the recycling bin. – Hand-E-Food Jan 22 '12 at 21:43
-3

Are you wanting to mirror source and destination?
ROBOCOPY /MIR

It might be worth looking at the /FFT switch as well

You could of course use RAID 1, but I prefer having the discrete drives for flexibility.

Having said that, I've found robocopy regularly re-copies files that don't need to be copied. Perhaps a service is tweaking the dates in the source so they appear later.

I would like to know how to skip files of the same size and ignore dates since I know the files haven't changed if the sizes are identical for my media files.

mattpm
  • 1,310
  • 2
  • 19
  • 26