[TriLUG] Search for Duplicate Filename, Ignore Extension

Igor Partola igor at igorpartola.com
Wed Nov 2 13:56:39 EDT 2011


Trying this out, this solution is cleaner than mine. Also, my use of cut is
broken: it fails on filenames like 'a.b.c', whereas Robert's doesn't.

As for the filenames, just use / as the delimiter since it is an illegal
character for a file base name to contain.

Igor

On Wed, Nov 2, 2011 at 1:29 PM, Robert Dale <robdale at gmail.com> wrote:

> Generate database of files:
>
> find . -type f | while read file; do echo `basename
> "${file%.*}"`\#${file}; done > files.txt
>
> Find dupes:
>
> cat files.txt | cut -f 1 -d '#' | sort | uniq -c | grep -v "^.*1" |
> awk '{print $2}' | while read dupe; do grep -i ${dupe}\# files.txt;
> done
>
> Caveats:
> database delimiter is '#' so if you have those in your filename, well,
> shame on you.
>



More information about the TriLUG mailing list