View unanswered posts | View active topics It is currently 18 Apr 2014 08:12



Post new topic Reply to topic  [ 6 posts ] 
Copy files do not overwrite existing 
Author Message

Joined: 30 May 2009 15:41
Posts: 2
Post Copy files do not overwrite existing
Hi there,
In the spirit of DIY I would like to create a batch file to backup my music library, however I would like to it to only add new files to the backup.

something like:
Code:
COPY E:\*.mp3 F:\music\

What would I need to do to make sure that it doesn't overwrite files that already exist?

Thanks


30 May 2009 15:49
Profile
Expert

Joined: 04 Feb 2009 10:03
Posts: 80
Post 
Use the copy /-Y option

Something like:

COPY /-Y E:\*.mp3 F:\music\

This will prompt you to overwrite or not. That way, you can copy them all, or overwrite as it's copying. But, it won't overwrite unless you tell it to.

-Rick


30 May 2009 23:27
Profile

Joined: 30 May 2009 15:41
Posts: 2
Post 
Thanks Rick,
That worked great for initially copying my files over but when I tried my first "Backup" it prompted me to overwrite each file individually.

Code:
COPY /-Y E:\*.mp3 F:\music\
E:\01 Limehouse Blues.mp3
Overwrite F:\MP3Mass\01 Limehouse Blues.mp3? (Yes/No/All):


I would like the script to only copy new files over (files that do not exist in the backup folder, to save time)

Perhaps I need to send the output to a loop that returns "no"?
Or maybe I should compare the files in the two locations first, then only copy new files over with a more elaborate script?


31 May 2009 13:04
Profile
Expert

Joined: 04 Feb 2009 10:03
Posts: 80
Post 
OK.. try this then:

XCopy /-U E:\*.mp3 F:\music\

The /U option will only copy files that already exist. The /-U should copy only those that do not already exist.

-Rick


31 May 2009 15:41
Profile
Expert

Joined: 19 Mar 2009 08:47
Posts: 391
Location: Iowa
Post 
If you want to take the time to learn it, robocopy is an excellent tool designed just for this type of thing.

From the resource toolkit.


01 Jun 2009 11:35
Profile

Joined: 13 Dec 2010 10:32
Posts: 79
Post Re: Copy files do not overwrite existing
Old topic, but I thought I would post.

pipe an 'n' to each question on the overwrite. the /-y is required in batch files or it assumes /y.
Code:
echo n|copy /-y c:\source\* c:\destination\*


13 Dec 2010 10:38
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 


Who is online

Users browsing this forum: Baidu [Spider], Google [Bot] and 26 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Forum style by Vjacheslav Trushkin for Free Forums/DivisionCore.