Copying files - duplicate filnames
September 10, 2007 4:30 AM   Subscribe

I want to copy files, ignoring & logging it if the target directory contains files with the same name. (Ubuntu 7.04)

I have a large number of CD-Rs & DVD-Rs containing files (mostly mp3s, but I don't think that's particularly relevant to the problem at hand) organised which I would like to copy to my hard disk, on a Ubuntu 7.04 system.

For each disc, I want to issue a single command (via command line or GUI, it doesn't matter) and have all the files recursively copied to the hard disk, retaining the directory structure. If a file with the same name already exists in the same directory in the target filesystem I would like it to be skipped and for this to be logged. I don't want the copying process to be interrupted with overwrite/ignore-type messages.

Ideally, the identical filename situation would *not* be logged if the files were also identical in size (or even better, if they had the same hash). Also in a perfect world, the log would contain not only the names of skipped files, but also their size.

The --update argument to cp automates the 'identical filename' issue, but it is concerned with whether one file is more recent than another and that is not important to me.

I've looked at Unison File Synchronizer, but can't see a way to get it to do what I want.

Thanks!
posted by Busy Old Fool to Computers & Internet (6 answers total)
 
you could probably write a bash script, using find, cmp and cp. I don't have time to write it right now, but you can probably do it.
posted by DarkForest at 5:40 AM on September 10, 2007


Best answer: You need rsync.

From the man page, I think you'll find the following options useful.

--ignore-existing skip updating files that exist on receiver

Also:
-r, --recursive recurse into directories
-u, --update skip files that are newer on the receiver
--inplace update destination files in-place
--append append data onto shorter files
-i, --itemize-changes output a change-summary for all updates
posted by geminus at 5:59 AM on September 10, 2007


as per geminus, rsync is where it's at. Or "Perl is your friend" but that's a lot of work for a simple problem like this.
posted by polyglot at 6:55 AM on September 10, 2007


3rding rsync. You might be able to bolt together something in a shell script with 'find', but rsync would be easier/cleaner.
posted by jquinby at 12:10 PM on September 10, 2007


Response by poster: I'm sitting on the fence until a fourth person suggests rsync...

Actually, when I was researching previous answers, I did find reference to rysnc, but for some reason decided it couldn't do what I wanted. I'll go back and look in earnest.

Thanks, all!
posted by Busy Old Fool at 7:08 AM on September 11, 2007


with a shell script, you could get exactly what you want, but it does sound like rsync gets you 99% of the way there, so I'll give you your fourth on that.
posted by DarkForest at 8:49 AM on September 11, 2007


« Older Help My School Get a .EDU!   |   Help me find a specific piece of music Newer »
This thread is closed to new comments.