Page 1 of 1

copy files with exclude

Posted: 15 Jan 2014 08:49
by mor.bas
Hi,
I need batch file that can use xcopt,robocopy...
It's copy from source to dest only the files that on dest are empty files(with 0 size).
like copy not overwrite but only for empty files on dest...
Thanks in advance...

Re: copy files with exclude

Posted: 15 Jan 2014 11:06
by Squashman
Well I think you would start by using a for loop to check the file size of the destination files.
If the File size is Zero Then use an IF EXIST command to see if the same file name exists in the source and If it does then copy the source to the destination.

Re: copy files with exclude

Posted: 15 Jan 2014 21:11
by foxidrive
Robocopy has the /MAX:0 switch that will exclude files bigger than n bytes. Here it is shown with 0 bytes.

Re: copy files with exclude

Posted: 16 Jan 2014 06:13
by Squashman
foxidrive wrote:Robocopy has the /MAX:0 switch that will exclude files bigger than n bytes. Here it is shown with 0 bytes.

But I would assume that would be for the source file and not the destination.

Re: copy files with exclude

Posted: 16 Jan 2014 07:16
by foxidrive
Yes, that's right. I hadn't considered that the OP had created zero byte files in the destination.

Hmmm, he says this:

like copy not overwrite but only for empty files on dest...


I'm a little confused. So copy but not overwrite zero byte files.

Xcopy with /D can do that if you update the timestamps on all the zero byte files.
That might work.

Re: copy files with exclude

Posted: 16 Jan 2014 07:26
by Squashman
foxidrive wrote:Yes, that's right. I hadn't considered that the OP had created zero byte files in the destination.

Hmmm, he says this:

like copy not overwrite but only for empty files on dest...


I'm a little confused. So copy but not overwrite zero byte files.

Yes. Technically you would have to overwrite them in the destination.

Re: copy files with exclude

Posted: 16 Jan 2014 07:28
by foxidrive
Xcopy with /D can do that if you update the timestamps on all the zero byte files with a script.

That might work.

EDIT:

It's copy from source to dest only the files that on dest are empty files(with 0 size).


Hmm Now I am confused again.

mor.bas, which files are meant to be excluded? The zero byte files? Or every file which is not zero bytes?

Re: copy files with exclude

Posted: 16 Jan 2014 08:53
by Squashman
foxidrive wrote:Xcopy with /D can do that if you update the timestamps on all the zero byte files with a script.

That might work.

EDIT:

It's copy from source to dest only the files that on dest are empty files(with 0 size).


Hmm Now I am confused again.

mor.bas, which files are meant to be excluded? The zero byte files? Or every file which is not zero bytes?

I think they really meant to say include and not exclude. If you want to copy the zero byte files that would be an include.
If you don't want to copy zero byte files in the destination then it would be an exclude.

Re: copy files with exclude

Posted: 16 Jan 2014 09:00
by foxidrive
It says exclude in the thread subject, so I followed with that.