in reply to Finding files in unix irrespective of case

Okay maybe this is what you want:
open MISS, 'missing.txt' or die "Cant open missing: $!\n"; my %missing = map {(lc($_),$_)} <MISS>; close MISS; opendir DIR, '.' or die "Can't open pwd: $!\n"; while (defined($_=readdir(DIR))) { # convert filename to lowercase and see if it is in list if (exists $missing{lc($_)} ) { symlink($_, $missing{lc($_)}); delete $missing{lc($_)}; } } closedir DIR; print "Still not found:\n\n" . join("\n", keys %missing) . "\n";
Updated: So the hash keys and input filenames are now compared in lowercase, but the symlinks are done with both original cases.
If you need to rename the files recursivly then be sure to use File::Find.

Replies are listed 'Best First'.
Re: Re: Finding files in unix irrespective of case
by ashok (Sexton) on Jan 06, 2001 at 07:19 UTC
    Hi, I appreciate your help. In this code you are converting the file name's all characters to lowercase and searching the directory. If user includes the file like
    #include <Myheader.H>
    then your logic will fail. So it requires to check both lower and upper case for each letter in a file name while searching in the directory. Infact we can put all the filenames user supplied in an array and convert those all file names into lower case and create a hash and compare with the file names in "missing.txt" file. But I think it is laborious and may not be a good idea. Thanks Ashok