DosTips.com

A Forum all about DOS Batch
It is currently 27 Jul 2016 05:34

All times are UTC-06:00




Post new topic  Reply to topic  [ 6 posts ] 
Author Message
PostPosted: 30 May 2009 15:49 
Offline

Joined: 30 May 2009 15:41
Posts: 2
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


Top
   
 Post subject:
PostPosted: 30 May 2009 23:27 
Offline
Expert

Joined: 04 Feb 2009 10:03
Posts: 80
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


Top
   
 Post subject:
PostPosted: 31 May 2009 13:04 
Offline

Joined: 30 May 2009 15:41
Posts: 2
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?


Top
   
 Post subject:
PostPosted: 31 May 2009 15:41 
Offline
Expert

Joined: 04 Feb 2009 10:03
Posts: 80
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


Top
   
 Post subject:
PostPosted: 01 Jun 2009 11:35 
Offline
Expert

Joined: 19 Mar 2009 08:47
Posts: 391
Location: Iowa
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.


Top
   
PostPosted: 13 Dec 2010 10:38 
Offline

Joined: 13 Dec 2010 10:32
Posts: 79
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\*


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 6 posts ] 

All times are UTC-06:00


Who is online

Users browsing this forum: douglas.swehla, Google [Bot], penpen, Yahoo [Bot] and 19 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® Forum Software © phpBB Limited