Results 1 to 3 of 3
Hi, I am trying to copy a load of files from an old computer to my Gentoo box. Over a wireless (b) network this has been slightly flakey but I'm ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 01-21-2008 #1
- Join Date
- Jan 2008
Skip duplicate files with copy (cp)
I am trying to copy a load of files from an old computer to my Gentoo box. Over a wireless (b) network this has been slightly flakey but I'm pretty much there.
What I would like to do now is run the copy command again, but have it automatically skip the files that already exist. Thus far I have been using the -i interactive switch but then I have to press enter to skip each duplicate.
Can anyone suggest an elegant alternative?
- 01-21-2008 #2
This isn't as elegant as I think you are looking for, but could you use the update flag?
copy only when the SOURCE file is newer than the destination
file or when the destination file is missing
You would have to be a bit careful just because it just looks at the timestamp, but will at least you won't have to sit in front of the terminal and babysit the copy.
I also found this but have never used it. However, it may be what you are looking for.
*Deprecated: to be removed in 2008.*
Using `--reply=yes' makes `cp' act as if `yes' were given as a
response to every prompt about a destination file. That
effectively cancels any preceding `--interactive' or `-i' option.
Specify `--reply=no' to make `cp' act as if `no' were given as a
response to every prompt about a destination file. Specify
`--reply=query' to make `cp' prompt the user about each existing
What you would do (I think) is do cp -i --reply=no
That way, it will ask if you want to overwrite the file and automatically say "no." Check your version and give it a test run as this option will be removed very soon!
Last edited by sdimhoff; 01-21-2008 at 01:51 PM. Reason: Found a better way
- 01-24-2008 #3
- Join Date
- Jan 2008
That's really useful thanks. I had thought of the update option, but it hadn't worked for me in the past. I now realise my clock was set wrong so in the future that should work just fine.
seems like a shame to get rid of the --reply option as this was maybe more appropriate for my needs as I was copying music and so am not really bothered by the date stamp.