Mercurial > ec-dotfiles
comparison bin/rmcrc @ 123:173833e4ba35
Merge.
author | Edho Prima Arief <edho@myconan.net> |
---|---|
date | Wed, 26 Oct 2011 15:15:39 +0700 |
parents | 66c32422a3d4 |
children |
comparison
equal
deleted
inserted
replaced
122:eacc854eae67 | 123:173833e4ba35 |
---|---|
1 #!/usr/bin/env perl | |
2 | |
3 use warnings; | |
4 use strict; | |
5 use File::Basename; | |
6 | |
7 my @files = @ARGV or print("Usage: ",basename($0)," file1 ... fileN\n") && exit(1); | |
8 my $skip=0; | |
9 foreach (@files) { | |
10 print(qq(Could not find file "$_", skipping\n)) and next() unless -e $_; | |
11 my $newname = $_; | |
12 $newname =~ s/\[[[:xdigit:]]{8}\]//i; | |
13 $newname =~ s/ *(\.\w+)$/$1/; | |
14 print(qq($_: $newname already exists, skipping\n)) and next() if -e $newname and $_ ne $newname; | |
15 if ($_ eq $newname) { | |
16 print("$_: no need to rename, skipping\n"); | |
17 } else { | |
18 if($skip==1) { print("Result: $_ --> $newname\n"); } | |
19 else { | |
20 if(rename($_, $newname)) { print("$_ -> $newname\n"); } | |
21 else { print("$_: rename failed\n"); } | |
22 } | |
23 } | |
24 next(); | |
25 } | |
26 | |
27 exit(0); |