Mercurial > ec-dotfiles
annotate bin/lren @ 702:48b0cfae98be
Update email in license
author | nanaya <me@nanaya.net> |
---|---|
date | Mon, 31 Oct 2022 20:42:42 +0900 |
parents | 94ee419ad047 |
children |
rev | line source |
---|---|
4
94ee419ad047
Added bin-ec - a collection of scripts.
Edho Prima Arief <me@myconan.net>
parents:
diff
changeset
|
1 #!/usr/bin/env perl |
94ee419ad047
Added bin-ec - a collection of scripts.
Edho Prima Arief <me@myconan.net>
parents:
diff
changeset
|
2 |
94ee419ad047
Added bin-ec - a collection of scripts.
Edho Prima Arief <me@myconan.net>
parents:
diff
changeset
|
3 use warnings; |
94ee419ad047
Added bin-ec - a collection of scripts.
Edho Prima Arief <me@myconan.net>
parents:
diff
changeset
|
4 use strict; |
94ee419ad047
Added bin-ec - a collection of scripts.
Edho Prima Arief <me@myconan.net>
parents:
diff
changeset
|
5 use File::Basename; |
94ee419ad047
Added bin-ec - a collection of scripts.
Edho Prima Arief <me@myconan.net>
parents:
diff
changeset
|
6 |
94ee419ad047
Added bin-ec - a collection of scripts.
Edho Prima Arief <me@myconan.net>
parents:
diff
changeset
|
7 my @files = @ARGV or print("Usage: ",basename($0)," file1 ... fileN\n") && exit(1); |
94ee419ad047
Added bin-ec - a collection of scripts.
Edho Prima Arief <me@myconan.net>
parents:
diff
changeset
|
8 my $skip=0; |
94ee419ad047
Added bin-ec - a collection of scripts.
Edho Prima Arief <me@myconan.net>
parents:
diff
changeset
|
9 foreach (@files) { |
94ee419ad047
Added bin-ec - a collection of scripts.
Edho Prima Arief <me@myconan.net>
parents:
diff
changeset
|
10 my $newname = $_; |
94ee419ad047
Added bin-ec - a collection of scripts.
Edho Prima Arief <me@myconan.net>
parents:
diff
changeset
|
11 print(qq(Could not find file "$_", skipping\n)) and next() unless -e $_; |
94ee419ad047
Added bin-ec - a collection of scripts.
Edho Prima Arief <me@myconan.net>
parents:
diff
changeset
|
12 $newname =~ s/_/ /g; |
94ee419ad047
Added bin-ec - a collection of scripts.
Edho Prima Arief <me@myconan.net>
parents:
diff
changeset
|
13 $newname =~ s/.* Ep([[:digit:]]+) .*/[Anime-Takeover] You're Under Arrest! - $1 [v2].mkv/; |
94ee419ad047
Added bin-ec - a collection of scripts.
Edho Prima Arief <me@myconan.net>
parents:
diff
changeset
|
14 $newname =~ s/ +/ /g; |
94ee419ad047
Added bin-ec - a collection of scripts.
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; |
94ee419ad047
Added bin-ec - a collection of scripts.
Edho Prima Arief <me@myconan.net>
parents:
diff
changeset
|
16 if ($_ eq $newname) { |
94ee419ad047
Added bin-ec - a collection of scripts.
Edho Prima Arief <me@myconan.net>
parents:
diff
changeset
|
17 print("$_: no need to rename, skipping\n"); |
94ee419ad047
Added bin-ec - a collection of scripts.
Edho Prima Arief <me@myconan.net>
parents:
diff
changeset
|
18 } else { |
94ee419ad047
Added bin-ec - a collection of scripts.
Edho Prima Arief <me@myconan.net>
parents:
diff
changeset
|
19 if($skip==1) { print("Result: $_ --> $newname\n"); } |
94ee419ad047
Added bin-ec - a collection of scripts.
Edho Prima Arief <me@myconan.net>
parents:
diff
changeset
|
20 else { |
94ee419ad047
Added bin-ec - a collection of scripts.
Edho Prima Arief <me@myconan.net>
parents:
diff
changeset
|
21 if(rename($_, $newname)) { print("$_ -> $newname\n"); } |
94ee419ad047
Added bin-ec - a collection of scripts.
Edho Prima Arief <me@myconan.net>
parents:
diff
changeset
|
22 else { print("$_: rename failed\n"); } |
94ee419ad047
Added bin-ec - a collection of scripts.
Edho Prima Arief <me@myconan.net>
parents:
diff
changeset
|
23 } |
94ee419ad047
Added bin-ec - a collection of scripts.
Edho Prima Arief <me@myconan.net>
parents:
diff
changeset
|
24 } |
94ee419ad047
Added bin-ec - a collection of scripts.
Edho Prima Arief <me@myconan.net>
parents:
diff
changeset
|
25 next(); |
94ee419ad047
Added bin-ec - a collection of scripts.
Edho Prima Arief <me@myconan.net>
parents:
diff
changeset
|
26 } |
94ee419ad047
Added bin-ec - a collection of scripts.
Edho Prima Arief <me@myconan.net>
parents:
diff
changeset
|
27 |
94ee419ad047
Added bin-ec - a collection of scripts.
Edho Prima Arief <me@myconan.net>
parents:
diff
changeset
|
28 exit(0); |