3 Synchronize filename cases for extensions.
5 This script could be used to perform following renaming:
6 if there exist file, for example, "FiLeNaME.c" and
7 filename.obj then it renames "filename.obj" to "FiLeNaME.obj".
8 There is a problem when some compilers (e.g.Borland) generate
9 such .obj files and then "make" process will not treat them
10 as dependant and already maked files.
12 This script takes two arguments - first and second extensions to
13 synchronize filename cases with.
15 There may be specified following options:
16 --verbose <== say everything what is going on
17 --recurse <== recurse subdirectories
18 --dummy <== do not perform actual renaming
20 Every such option can be specified with an optional "no" prefix to negate it.
22 Typically, it is invoked as:
23 perl sync_ext.pl c obj --verbose
29 my ($ext1, $ext2) = map {quotemeta} grep {!/^--/} @ARGV;
37 (map {/^--([\-_\w]+)=(.*)$/} @ARGV), # --opt=smth
38 (map {/^no-?(.*)$/i?($1=>0):($_=>1)} map {/^--([\-_\w]+)$/} @ARGV), # --opt --no-opt --noopt
45 my @f = map {/^(.*)\.$ext1$/i} @t;
46 my %f = map {lc($_)=>$_} map {/^(.*)\.$ext2$/i} @t;
49 if (exists $f{$lc} and $f{$lc} ne $_) {
50 print STDERR "$sp$f{$lc}.$ext2 <==> $_.$ext1\n" if $opts{verbose};
52 print STDERR "ren $f{$lc}.$ext2 $_.$ext2\n";
55 system "ren $f{$lc}.$ext2 $_.$ext2";
60 for (grep {-d&&!/^\.\.?$/} @t) {
61 print STDERR "$sp\\$_\n" if $opts{'say-subdir'};