I'd like to know if it's possible to move/copy files using the command line and automatically rename conflicting files? I scoured the forums and found different suggestions but none of them worked. So far I've tried:
cp -r --backup=t /path/to/source /path/to/target
cp --backup=numbered /path/to/source /path/to/target
cp -R --backup=existing --suffix=.orig -t /path/to/source /path/to/target
It's a large folder (700GB) which contains a lot of old files. The third command "kinda" worked (on some files), but I noticed that it didn't work on certain other files, since I left the PC on tonight to transfer the files and checked if it had overwritten anything (which it had).
Thank you for your help.
rsync -b
is worth an answer.cp --archive --backup --suffix="-original" A/* B
but this overwrites the file if there already is an-original
- is there any way to make it copy files incrementally? Like:example.txt
,example.txt.original
,example.txt.original.1
,.2
and so forth?cp
was able to perform such a task, but he told me that I would need to script loops in order forcp
to be able to do so. Thanks for the help everyone.