I have a huge file tree. Some files have same name but in different case, e.g., some_code.c
and Some_Code.c
.
So when I'm trying to copy it to an NTFS/FAT filesystem, it asks me about whether I want it to replace the file or skip it.
Is there any way to automatically rename such files, for example, by adding (1)
to the name of conflict file (as Windows 7 does)?
Best Answer
Many GNU tools such as
cp
,mv
andtar
support creating backup files when the target exists. That is, when copyingfoo
tobar
, if there is already a file calledbar
, the existingbar
will be renamed, and after the copybar
will contain the contents offoo
. By default,bar
is renamed tobar~
, but the behavior can be modified:There are other variants, such as creating numbered backups only when one already exists. See the coreutils manual for more details.