summaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authorVadim Konovalov <vkonovalov@lucent.com>2001-03-10 22:26:07 +0300
committerJarkko Hietaniemi <jhi@iki.fi>2001-03-15 15:09:32 +0000
commit3b48d85d1f08ba7ec4fa46512fef5124222d20fb (patch)
treec624ad353c4e883c31ec491de99d24e40662a61a /win32
parent47a334e99a6f8afdee73613c4a17ed090015ff78 (diff)
downloadperl-3b48d85d1f08ba7ec4fa46512fef5124222d20fb.tar.gz
Re: Another Borland C++ problem.
Message-ID: <001601c0a97f$143fcc40$da7b55c2@vad> Borland filename case problem. p4raw-id: //depot/perl@9171
Diffstat (limited to 'win32')
-rw-r--r--win32/sncfnmcs.pl63
1 files changed, 63 insertions, 0 deletions
diff --git a/win32/sncfnmcs.pl b/win32/sncfnmcs.pl
new file mode 100644
index 0000000000..bb62460ea0
--- /dev/null
+++ b/win32/sncfnmcs.pl
@@ -0,0 +1,63 @@
+=comment
+
+Synchronize filename cases.
+This script takes two arguments - first and second extensions to synchronize
+filename cases with.
+
+There may be specified following options:
+ --verbose <== say everything what is going on
+ --recurse <== recurse subdirectories
+ --dummy <== do not perform actual renaming
+ --say-subdir
+Every such option can be specified with an optional "no" prefix to negate it.
+
+Typically, it is invoked as:
+ perl sync-fnamescase.pl c obj --verbose
+
+=cut
+
+use strict;
+
+my ($ext1, $ext2) = map {quotemeta} grep {!/^--/} @ARGV;
+my %opts = (
+ #defaults
+ 'verbose' => 0,
+ 'recurse' => 1,
+ 'dummy' => 0,
+ 'say-subdir' => 0,
+ #options itself
+ (map {/^--([\-_\w]+)=(.*)$/} @ARGV), # --opt=smth
+ (map {/^no-?(.*)$/i?($1=>0):($_=>1)} map {/^--([\-_\w]+)$/} @ARGV), # --opt --no-opt --noopt
+ );
+
+my $sp = '';
+sub xx {
+ opendir DIR, '.';
+ my @t = readdir DIR;
+ my @f = map {/^(.*)\.$ext1$/i} @t;
+ my %f = map {lc($_)=>$_} map {/^(.*)\.$ext2$/i} @t;
+ for (@f) {
+ my $lc = lc($_);
+ if (exists $f{$lc} and $f{$lc} ne $_) {
+ print STDERR "$sp$f{$lc}.$ext2 <==> $_.$ext1\n" if $opts{verbose};
+ if ($opts{dummy}) {
+ print STDERR "ren $f{$lc}.$ext2 $_.$ext2\n";
+ }
+ else {
+ system "ren $f{$lc}.$ext2 $_.$ext2";
+ }
+ }
+ }
+ if ($opts{recurse}) {
+ for (grep {-d&&!/^\.\.?$/} @t) {
+ print STDERR "$sp\\$_\n" if $opts{'say-subdir'};
+ $sp .= ' ';
+ chdir $_ or die;
+ xx();
+ chdir ".." or die;
+ chop $sp;
+ }
+ }
+}
+
+xx();