I am transferring a large number of files on a HFS+ filesystem.
The files are currently on ext2 partitions.
I have conflicts due to case insensitivity of the target partition (HFS+).
I want to identify the files that have duplicates filenames once they are in lower case, and delete them if they are actually duplicates.
I also found that I will have duplicate folder names if I convert everyhing to lower case. Basically these hard drives contain years of unsorted data, and I happen to have this problem with folder names too.
Does this seem reasonable:
find . -type f | while read f; do echo $f:l; done | sort | uniq -d
$f:l
is ZSH for convert to lower case.
Now I want to keep only one instance of each file that have duplicates. How to do this efficiently ?
I do not want to find files with duplicate content, unless they have the same lower case filename. I will deal with duplicates later.
$f:l
you mean to convert$f
into lowercase, you should note that the POSIX way of doing that is${f,,*}
. Your code will break if a file name contains a newline. You should also note that it will not produce correct paths to the duplicate files because it will lowercase all the path components.