annotate bin/putend @ 256:227f4d463b5d

Color tester.
author Edho Arief <edho@myconan.net>
date Tue, 15 Nov 2011 12:10:28 +0700
parents 917b525eaee0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
88
917b525eaee0 Put [End] to files. Still in perl D:
Edho Prima Arief <me@myconan.net>
parents:
diff changeset
1 #!/usr/bin/env perl
917b525eaee0 Put [End] to files. Still in perl D:
Edho Prima Arief <me@myconan.net>
parents:
diff changeset
2
917b525eaee0 Put [End] to files. Still in perl D:
Edho Prima Arief <me@myconan.net>
parents:
diff changeset
3 use warnings;
917b525eaee0 Put [End] to files. Still in perl D:
Edho Prima Arief <me@myconan.net>
parents:
diff changeset
4 use strict;
917b525eaee0 Put [End] to files. Still in perl D:
Edho Prima Arief <me@myconan.net>
parents:
diff changeset
5 use File::Basename;
917b525eaee0 Put [End] to files. Still in perl D:
Edho Prima Arief <me@myconan.net>
parents:
diff changeset
6
917b525eaee0 Put [End] to files. Still in perl D:
Edho Prima Arief <me@myconan.net>
parents:
diff changeset
7 my @files = @ARGV or print("Usage: ",basename($0)," file1 ... fileN\n") && exit(1);
917b525eaee0 Put [End] to files. Still in perl D:
Edho Prima Arief <me@myconan.net>
parents:
diff changeset
8 my $skip=0;
917b525eaee0 Put [End] to files. Still in perl D:
Edho Prima Arief <me@myconan.net>
parents:
diff changeset
9 foreach (@files) {
917b525eaee0 Put [End] to files. Still in perl D:
Edho Prima Arief <me@myconan.net>
parents:
diff changeset
10 print(qq(Could not find file "$_", skipping\n)) and next() unless -e $_;
917b525eaee0 Put [End] to files. Still in perl D:
Edho Prima Arief <me@myconan.net>
parents:
diff changeset
11 my $newname = $_;
917b525eaee0 Put [End] to files. Still in perl D:
Edho Prima Arief <me@myconan.net>
parents:
diff changeset
12 $newname =~ s/(\.[^.]+$)/[End]$1/;
917b525eaee0 Put [End] to files. Still in perl D:
Edho Prima Arief <me@myconan.net>
parents:
diff changeset
13 $newname =~ s/ (\[.*\])(\[End\])\./ $2$1./;
917b525eaee0 Put [End] to files. Still in perl D:
Edho Prima Arief <me@myconan.net>
parents:
diff changeset
14 $newname =~ s/([^ ])(\[End\]\.)/$1 $2/;
917b525eaee0 Put [End] to files. Still in perl D:
Edho Prima Arief <me@myconan.net>
parents:
diff changeset
15 print(qq($_: $newname already exists, skipping\n)) and next() if -e $newname and $_ ne $newname;
917b525eaee0 Put [End] to files. Still in perl D:
Edho Prima Arief <me@myconan.net>
parents:
diff changeset
16 if ($_ eq $newname) {
917b525eaee0 Put [End] to files. Still in perl D:
Edho Prima Arief <me@myconan.net>
parents:
diff changeset
17 print("$_: no need to rename, skipping\n");
917b525eaee0 Put [End] to files. Still in perl D:
Edho Prima Arief <me@myconan.net>
parents:
diff changeset
18 } else {
917b525eaee0 Put [End] to files. Still in perl D:
Edho Prima Arief <me@myconan.net>
parents:
diff changeset
19 if($skip==1) { print("Result: $_ --> $newname\n"); }
917b525eaee0 Put [End] to files. Still in perl D:
Edho Prima Arief <me@myconan.net>
parents:
diff changeset
20 else {
917b525eaee0 Put [End] to files. Still in perl D:
Edho Prima Arief <me@myconan.net>
parents:
diff changeset
21 if(rename($_, $newname)) { print("$_ -> $newname\n"); }
917b525eaee0 Put [End] to files. Still in perl D:
Edho Prima Arief <me@myconan.net>
parents:
diff changeset
22 else { print("$_: rename failed\n"); }
917b525eaee0 Put [End] to files. Still in perl D:
Edho Prima Arief <me@myconan.net>
parents:
diff changeset
23 }
917b525eaee0 Put [End] to files. Still in perl D:
Edho Prima Arief <me@myconan.net>
parents:
diff changeset
24 }
917b525eaee0 Put [End] to files. Still in perl D:
Edho Prima Arief <me@myconan.net>
parents:
diff changeset
25 next();
917b525eaee0 Put [End] to files. Still in perl D:
Edho Prima Arief <me@myconan.net>
parents:
diff changeset
26 }
917b525eaee0 Put [End] to files. Still in perl D:
Edho Prima Arief <me@myconan.net>
parents:
diff changeset
27
917b525eaee0 Put [End] to files. Still in perl D:
Edho Prima Arief <me@myconan.net>
parents:
diff changeset
28 exit(0);