#!/usr/bin/env perl # Copyright (c) 2007 TrueStep # Name: find-case-insensitive-dups.pl # Author: Rory Arms - http://www.TrueStep.com/ # CDate: 2007-11-02 # Description: Lists all filenames that would clash on a case-insensitive fs # Motivation: Moving data to a case-preserving/insensitive filesystem, like HFS # Tested with: Darwin 8, HFS #$Id: find-case-insensitive-dups.pl,v 1.1.1.1 2007/11/26 22:33:27 rorya Exp $ use File::Find; @ARGV = ('.') unless @ARGV; my $debug = 0; my @dir_contents; find( { preprocess => \&preprocess, wanted => \&wanted, }, @ARGV); sub preprocess { @dir_contents = @_; return @_; } sub wanted { print_debug("wanted(): \@dir_contents: @dir_contents"); for ($i = 0; $i <= @dir_contents; $i++) { if ($_ eq $dir_contents[$i]) { $dir_contents[$i] = ''; # empty this slot } # do case-insensitive matching if (lc($_) eq lc($dir_contents[$i])) { print($File::Find::dir . "/$_\n"); } } } sub print_debug { if ($debug > 0) { print("Debug: $_[0]\n"); } }