Copy all files, skip those already existing, and delete those in destination not in source
I'd use something like this:
robocopy <Source> <Destination> /E /COPY:DAT /XO /PURGE /R:1 /W:1
From robocopy's help:
/PURGE :: delete dest files/dirs that no longer exist in source.
/XO :: eXclude Older files.
Related videos on Youtube
Wilson
Updated on September 18, 2022Comments
-
Wilson over 1 year
I imagine this could be done with Robocopy - I want to copy my music library from its folder on my PC to my mp3 player. I have ~5000 songs, and I'll probably run the copy every time I add an album.
Now, just using Windows copy, I can say to skip pre-existing files and it will do so and run relatively fast. However, I want my destination (mp3 player) to reflect deleted music as well. I'm not sure if simply using a mirror command would do this - I assumed that wouldn't take into account pre-existing files.
Quick example:
Source folder:
song1.mp3 song3.mp3 song4.mp3
Destination folder BEFORE copying:
song1.mp3 song2.mp3 song3.mp3
Destination folder AFTER copying (Identical to source):
song1.mp3 song3.mp3 song4.mp3
The important point is that, while copying,
song1.mp3
andsong3.mp3
were skipped (NOT overwritten, or the copy will take forever - because I have many songs) andsong2.mp3
was deleted.-
nixda almost 11 yearsWhat file system is the source and target? If both are NTFS a simple robocopy
/MIR
command will do exactly what you describe. It won't overwrite existing files. For example my own command looks likerobocopy.exe "T:\music" "S:\music" /MIR /W:1 /R:1 /MT:8 /NDL
. If your target file system is FAT you face a problem which can be solved with the switch/FFT
-
-
gargoylebident over 2 yearsWhy
/xo
? Wouldn't/purge
suffice? Additionally, if OP has folders (e.g. albums), they'll probably want/e
(or/s
) too.