NDog
In a batch file I am writing I want robocopy to ONLY copy files that are of different file size from the source to the destination. These are large 1.4GB files, and I was previously using FC to compare them, however FC needs to to load the files to check them, and this takes too long on a network.
The reason I need to do this is that the destination and the source keep changing time stamps (as they are being read frequently), but they do not change file size.
If I run robocopy %source% %destination% /XO /XN, will this only overwrite the sources file to the destination if the sources file-size changes?
If not how can I do this?
Thanks
cmd, vbs, ps, bash
autoit, python, swift
----------------------------
#2 14 Jun 2006 21:45
Simon Sheppard
By default Robocopy will consider the file changed if the file size changes OR if the timestamp changes
so all you need is
robocopy %source% %destination%
----------------------------
#3 15 Jun 2006 02:57
NDog
In theory that is supposed to happen, however in reality when i use:
robocopy %source% %destination%
it copies older files
it copies newer files
even though the source and destination are identical!!!
(I checked them with comp)
This is the specific code (using fcmp.exe as its faster than COMP or FC)
Code: Select all
set file=14GBfile.txt
fcmp D:\myfiles\%file% \\games00\d$\myfiles\%file%
::files are identical!
robocopy D:\myfiles \\games00\d$\myfiles %file%
::still copies them as newer even though they are identical!!!
Code: Select all
set file=14GBfile.txt
fcmp D:\myfiles\%file% \\games00\d$\myfiles\%file%
if errorlevel 1 robocopy D:\myfiles \\games00\d$\myfiles %file%
so the question maybe I should ask is: how can i check the filesize of the files first, then if they mismatch, robocopy
(without using fc or comp or fcmp, since they load the files, I need to be able just to check the filesize without loading the entire 14gb files to compare them)
Thanks again.
cmd, vbs, ps, bash
autoit, python, swift
----------------------------
#4 15 Jun 2006 20:44
Simon Sheppard
- something like this
Code: Select all
FOR %%G in (%file1%) do set _size1=%%~zG
FOR %%G in (%file2%) do set _size2=%%~zG
IF %_file1%==%_file2% echo The files are same size
----------------------------
#5 16 Jun 2006 06:42
NDog
Thank you very much!
cmd, vbs, ps, bash
autoit, python, swift