chiark / gitweb /
fix-names script to mess with track filenames
[disorder] / scripts / fix-names
1 #! /usr/bin/perl -w
2 use strict;
3
4 my $act = 1;
5
6 for my $f (@ARGV) {
7     if($f =~ /^-/) {
8         if($f eq '-n') {
9             $act = 0;
10         } else {
11             die "$0: unknown option: $f\n";
12         }
13         next;
14     }
15     my $t = $f;
16     $t =~ s/[_ ]+/ /g;
17     $t =~ s/(?!(?<=\.)[A-Za-z0-9]+$)\b[a-z]/\U$&\E/g;
18     print "$f -> $t\n";
19     if($act) {
20         (rename $f, $t) or die "$0: $f -> $t: $!\n";
21     }
22 }