skip already available files destination

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
vishnuj
Posts: 4
Joined: 18 Dec 2013 04:06

skip already available files destination

#1 Post by vishnuj » 25 Mar 2014 22:14

I need to copy a set of files from source to destination on daily basis. So i need to skip the files already available on the destination directory.

If i use -y command while copying, it will ask confirmation to skip. But, i don't want to ask confirmation, it should skip always.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: skip already available files destination

#2 Post by foxidrive » 25 Mar 2014 22:49

robocopy with the /mir switch will mirror the folders, only copying new files and removing old ones. Is that what you want to do?

Test it on some dummy folders first.

vishnuj
Posts: 4
Joined: 18 Dec 2013 04:06

Re: skip already available files destination

#3 Post by vishnuj » 25 Mar 2014 23:05

I don't want to remove the old files which is already available in the destination folder. I just want to skip the files which is already available in the destination folder.

Suppose i have files name one.txt, two.txt, three.txt, four.txt,. etc in folder1... i want to copy all these files to folder2, which already contains one.txt and two.txt, So in this case these two files should skip from copying and i need the rest files in folder2.

RightBehindu
Posts: 26
Joined: 23 Dec 2013 07:07

Re: skip already available files destination

#4 Post by RightBehindu » 26 Mar 2014 01:01

Can you not simply make a if statement?

if not exist "one.txt" copy "one.txt" "Destination" etc...

or even:

:copy_one
if exist "one.txt" goto copy_two

etc...

Not sure if this is what you want but hope it helps.

Matt

Compo
Posts: 600
Joined: 21 Mar 2014 08:50

Re: skip already available files destination

#5 Post by Compo » 26 Mar 2014 03:36

Robocopy by default does not copy same files, it copies only those which are different. That means it will only copy a file with the same name if its file size or time stamp differs from that which already exists in the destination.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: skip already available files destination

#6 Post by foxidrive » 26 Mar 2014 06:25

vishnuj wrote:I don't want to remove the old files which is already available in the destination folder. I just want to skip the files which is already available in the destination folder.


Compo is right, so use robocopy with the /e switch.

Code: Select all

Robocopy "c:\folder1" "d:\folder2" /e

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: skip already available files destination

#7 Post by Squashman » 26 Mar 2014 06:31

RightBehindu wrote:Can you not simply make a if statement?

if not exist "one.txt" copy "one.txt" "Destination" etc...

or even:

:copy_one
if exist "one.txt" goto copy_two

etc...

Not sure if this is what you want but hope it helps.

Matt

You could but that would be more code and run slower than Robocopy.

Post Reply