Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Conditionally MOVE/COPY files on the basis of size

Jun
121
0
Hi

I have 2 different directories such that some files exist in both.

For the files that exist in both, if the file is larger in the 2nd directory, can I conditionally COPY/MOVE to the 1st directory?
I should wind up with 1st directory containing its files + the larger of the two files where the same filename.

I have been looking at for %a but not getting far.

Thanks

Stephen Howe
 
| I have 2 different directories such that some files exist in both.
|
| For the files that exist in both, if the file is larger in the 2nd
| directory, can I conditionally COPY/MOVE to the 1st directory? I
| should wind up with 1st directory containing its files + the larger
| of the two files where the same filename.
|
| I have been looking at for %a but not getting far.

No simple way. Try this (UNTESTED!!!):

pushd DIR2
do f in *
if isfile dir1\%f if %@filesize[dir1\%f] LT %@filesize[%f] copy %f dir1\%f
enddo
popd

If there may exist filenames that need to be quoted insert the command below
after DO:
set f=%@quote[%f]

You need to play with COPY options to achieve your goals about automatic
overwriting.
--
HTH, Steve
 

Similar threads

Back
Top