chiark / gitweb /
fix-names script to mess with track filenames
authorRichard Kettlewell <rjk@greenend.org.uk>
Tue, 30 Dec 2008 23:39:32 +0000 (23:39 +0000)
committerRichard Kettlewell <rjk@greenend.org.uk>
Tue, 30 Dec 2008 23:39:32 +0000 (23:39 +0000)
scripts/Makefile.am
scripts/fix-names [new file with mode: 0755]

index 87eaf26..fe004d2 100644 (file)
@@ -23,7 +23,7 @@ SEDFILES=setup teardown
 
 include ${top_srcdir}/scripts/sedfiles.make
 
-EXTRA_DIST=htmlman sedfiles.make text2c oggrename make-unidata \
+EXTRA_DIST=htmlman sedfiles.make text2c oggrename make-unidata fix-names \
        format-gcov-report make-version-string setup.in teardown.in macro-docs
 
 CLEANFILES=$(SEDFILES)
diff --git a/scripts/fix-names b/scripts/fix-names
new file mode 100755 (executable)
index 0000000..97845d2
--- /dev/null
@@ -0,0 +1,22 @@
+#! /usr/bin/perl -w
+use strict;
+
+my $act = 1;
+
+for my $f (@ARGV) {
+    if($f =~ /^-/) {
+       if($f eq '-n') {
+           $act = 0;
+       } else {
+           die "$0: unknown option: $f\n";
+       }
+       next;
+    }
+    my $t = $f;
+    $t =~ s/[_ ]+/ /g;
+    $t =~ s/(?!(?<=\.)[A-Za-z0-9]+$)\b[a-z]/\U$&\E/g;
+    print "$f -> $t\n";
+    if($act) {
+       (rename $f, $t) or die "$0: $f -> $t: $!\n";
+    }
+}