Mercurial > ec-dotfiles
comparison bin/ren @ 4:94ee419ad047
Added bin-ec - a collection of scripts.
author | Edho Prima Arief <me@myconan.net> |
---|---|
date | Sat, 10 Jul 2010 12:38:52 +0000 |
parents | |
children | 8a0391d8e8d0 |
comparison
equal
deleted
inserted
replaced
3:39ef7f7236fc | 4:94ee419ad047 |
---|---|
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 my $newname = $_; | |
11 print(qq(Could not find file "$_", skipping\n)) and next() unless -e $_; | |
12 $newname =~ s/Sakura\.Wars\.([[:digit:]]{2}).*/[AM] Sakura Wars - $1.mkv/; | |
13 #$newname =~ s/Legend Of The Crystals OAV - 0/- Legend of the Crystals OVA - /; | |
14 #$newname =~ s/^Kaleido_Star_-_([[:digit:]]{2}).*(\[[[:xdigit:]]{8}\]\.mkv)$/[joseole99] Kaleido Star - $1 [DVD]$2/i; | |
15 #$newname =~ s/^Kaleido_Star_-_Clean_ED([[:digit:]]).*(\[[[:xdigit:]]{8}\]\.mkv)$/[joseole99] Kaleido Star - Ending $1 (Clean) [DVD]$2/i; | |
16 #$newname =~ s/^Kaleido_Star_-_Clean_OP([[:digit:]]).*(\[[[:xdigit:]]{8}\]\.mkv)$/[joseole99] Kaleido Star - Opening $1 (Clean) [DVD]$2/i; | |
17 #$newname =~ s/.*_-_([[:digit:]]{2})\[47\].*(\[[[:xdigit:]]{8}\]\.mkv)$/[AniMecha] - $1 [DVD]$2/i; | |
18 #$newname =~ s/.*\.([[:digit:]]{2})\.\[.*([[:xdigit:]]{8}\]\.mkv)$/[Arigatou] Blade of the Immortal - $1 [$2/i; | |
19 #$newname =~ s/.* ([[:digit:]]+) .*/[AonE-AnY] Ah My Goddess - $1.avi/; | |
20 #$newname =~ s/\[24-\(Final\)\]_/24 [End]/; | |
21 #$newname =~ s/\[([[:digit:]]{2})\]/$1/; | |
22 #$newname =~ s/^Otaku no Musume-san c([[:digit:]]+) \[v03\](\[.+\])\.zip$/Otaku no Musume-san - $1 (v03) $2.zip/i; | |
23 #$newname =~ s/ HQ //; | |
24 $newname =~ s/xvid//i; | |
25 $newname =~ s/^\[Doremi\]\.HeartCatch\.PreCure!\.([[:digit:]]{2})\.\[1280x720\]\.\[([[:xdigit:]]{8})\]\.mkv$/[Doremi] HeartCatch PreCure! - $1 (1280x720) [$2].mkv/; | |
26 $newname =~ s/^\[Doremi\]\.Motto\.Ojamajo\.Doremi\.([[:digit:]]{2})\.\[([[:xdigit:]]{8})\]\.avi$/[Doremi] Motto Ojamajo Doremi - $1 [$2].avi/; | |
27 $newname =~ s/^(Detective Conan - [[:digit:]]+-?[[:digit:]]*) (\[DCTP[^]]*\])(.+)$/$2 $1 $3/; | |
28 $newname =~ s/^(Detective Conan - OVA[[:digit:]]+-?[[:digit:]]*) (\[DCTP[^]]*\])(.+)$/$2 $1 $3/; | |
29 $newname =~ s/^(Kamen Rider W - [[:digit:]]+)HD (\[W-Time\])(.+)$/$2 $1 $3/; | |
30 $newname =~ s/- TV -/-/; | |
31 $newname =~ s/^(\[Keroro\])\.([[:digit:]]+)\..*(\[[[:xdigit:]]{8}\].+)$/$1 Keroro Gunsou - $2 $3/; | |
32 $newname =~ s/SubDESU(.*)_-_Directors_Cut/SubDesu$1/; | |
33 $newname =~ s/\[480p\]\.mkv$/.mkv/; | |
34 $newname =~ s/^(\[EG\])ZZ_Gundam_BD_([[:digit:]]+)\(720p\)(.+)$/$1 Gundam ZZ - $2 (960x720) [BD]$3/; | |
35 $newname =~ s/\]_Working_-/] Working!! -/; | |
36 $newname =~ s/WORKING!!/Working!!/; | |
37 $newname =~ s/\[Retrofit\]_\[Ayako-m\.3\.3\.w\.\]/[Retrofit-Ayako-m.3.3.w]/i; | |
38 $newname =~ s/Rosario\+Vampire/Rosario + Vampire/i; | |
39 $newname =~ s/Rosario \+ Vampire - Capu2 - /Rosario + Vampire Capu 2 - /i; | |
40 $newname =~ s/ Hidamari Sketch Hoshimittsu / Hidamari Sketch - Hoshi Mittsu /i; | |
41 $newname =~ s/ HEROMAN / Heroman /i; | |
42 #$newname =~ s/^/[ETB]/i; | |
43 $newname =~ s/_/ /g; | |
44 $newname =~ s/ ARIA The ORIGINATION / Aria the Origination /i; | |
45 $newname =~ s/ ARIA The NATURAL / Aria the Natural /i; | |
46 $newname =~ s/^Clannad Ep([[:digit:]]+) \[1080p,BluRay,x264\] - THORA\.mkv$/[THORA] Clannad - $1 (1920x1080) [BD].mkv/i; | |
47 $newname =~ s/ Mahou Kishi Rayearth / Magic Knight Rayearth /i; | |
48 $newname =~ s/rune soldier ep/ Rune Soldier /i; | |
49 $newname =~ s/ Harukanaru Toki no Naka de Hachiyoushou / Haruka Naru Toki no Naka de - Hachiyoushou /i; | |
50 $newname =~ s/ Harukanaru Toki no Naka de - / Haruka Naru Toki no Naka de - Hachiyoushou /i; | |
51 $newname =~ s/ -Hachiyoushou - / - Hachiyoushou - /i; | |
52 $newname =~ s/\[Retrofit\] \[Shinsen\] /[Retrofit-SHS] /i; | |
53 $newname =~ s/ You're Under Arrest - / You're Under Arrest! - /i; | |
54 $newname =~ s/ Rosario to Vampire / Rosario + Vampire /i; | |
55 $newname =~ s/\[R2 Video\]//i; | |
56 $newname =~ s/ \(BD-720p\) \[/ (1280x720) [BD][/i; | |
57 $newname =~ s/ TV Ep/ - /i; | |
58 $newname =~ s/\] AIR - /] Air - /i; | |
59 $newname =~ s/ - Episode / - /i; | |
60 $newname =~ s/\[divx[[:digit:].]+\]//i; | |
61 $newname =~ s/\[BD\] \(1280x720\) \[/(1280x720) [BD][/i; | |
62 $newname =~ s/ Seiken no Blacksmith / The Sacred Blacksmith /i; | |
63 #$newname =~ s/^Rizelmine([[:digit:]]+)\.avi$/[AC] Rizelmine - $1.avi/i; | |
64 $newname =~ s/\[v2\]/v2/i; | |
65 $newname =~ s/\.AAC\]//; | |
66 $newname =~ s/ No / no /g; | |
67 #$newname =~ s/ 0([[:digit:]]) / $1 /; | |
68 $newname =~ s/\[1280x720\]/(1280x720) /; | |
69 #$newname =~ s/^.*( [[:digit:]]{2}v2).*(\[[[:xdigit:]]{8}\]\.mkv)$/[KAA] Ai Yori Aoshi - $1 [DVD]$2/; | |
70 $newname =~ s/ True Tears / true tears /i; | |
71 $newname =~ s/ Fate stay night TV Reproduction / Fate-stay night - TV Reproduction /i; | |
72 $newname =~ s/ The Tatami Galaxy \(Yojouhan Shinwa Taikei\) / The Tatami Galaxy /i; | |
73 $newname =~ s/ Saint Seiya The Lost Canvas / Saint Seiya - The Lost Canvas /i; | |
74 $newname =~ s/Mayoi Neko Overrun /Mayoi Neko Overrun! /; | |
75 $newname =~ s/Angel Beats /Angel Beats! /i; | |
76 $newname =~ s/Rainbow /Rainbow /i; | |
77 $newname =~ s/ Ookiku Furikabutte - The Summer Tournament Chapter / Ookiku Furikabutte S2 /i; | |
78 $newname =~ s/Senko no night raid /Senkou no Night Raid /i; | |
79 $newname =~ s/To Heart Mini Ep0/To Heart - Special /; | |
80 $newname =~ s/Mai Otome/Mai-Otome/i; | |
81 $newname =~ s/WORKING!!/Working!!/i; | |
82 $newname =~ s/ Sengoku Basara / Sengoku Basara /i; | |
83 $newname =~ s/ K-on!! S2 / K-ON!! /i; | |
84 #$newname =~ s/.*\[([[:digit:]]{2})\].*(\[[[:xdigit:]]{8}\]\.mkv)/[FuktLogik] Hidamari Sketch - $1 [DVD]$2/; | |
85 $newname =~ s/\(BD\) \[/ [BD][/i; | |
86 $newname =~ s/\[\[BD\]/[BD][/; | |
87 $newname =~ s/\(DVD \)/[DVD]/; | |
88 $newname =~ s/ AC3\]/ /; | |
89 $newname =~ s/ *(\.[[:alnum:]]+)[^[:alnum:]]*$/$1/; | |
90 $newname =~ s/\[webrip\]/[Webrip]/i; | |
91 $newname =~ s/\[[^]]*(640x360|[[:digit:]]{3}x480)[^]]*\]//; | |
92 $newname =~ s/([^]])\[/$1 [/; | |
93 #$newname =~ s/- .*x264 AAC\)//; | |
94 #$newname =~ s/ 0([[:digit:]]) / $1 /; | |
95 #$newname =~ s/ - Great Guardians OVA - / Great Guardians - Special - /; | |
96 #$newname =~ s/ ([\d]) / 0$1 /; | |
97 #$newname =~ s/.* ([\d]{2}) .*/[HL] Gundam ZZ - $1.mkv/; | |
98 #$newname =~ s/ \[[[:xdigit:]]{8}\]//; | |
99 $newname =~ s/^\(([^)]+)\)/[$1]/; | |
100 $newname =~ s/sonic x/Sonic X/i; | |
101 $newname =~ s/END/End/; | |
102 #$newname =~ s/\[[^]]*h\.?264[^]]*\]//; | |
103 $newname =~ s/h\.?264//i; | |
104 $newname =~ s/ op([\d]) / Opening $1 /i; | |
105 $newname =~ s/ ed([\d]) / Ending $1 /i; | |
106 $newname =~ s/ dragonball / Dragon Ball /i; | |
107 $newname =~ s/Kissxsis/ Kiss x Sis /i; | |
108 $newname =~ s/k-on/K-ON/i; | |
109 #$newname =~ s/ dvd (\(.*\) )?\[/ $1 [DVD][/i; | |
110 $newname =~ s/ ([\d]+)( |\.)/ - $1$2/; | |
111 $newname =~ s/\(([[:xdigit:]]{8})\)/[$1]/; | |
112 $newname =~ s/ ep([\d]+) / - $1 /i; | |
113 $newname =~ s/- \[/ [/; | |
114 $newname =~ s/&/ & /g; | |
115 $newname =~ s/ ([\d]{2})\[/ $1 [/; | |
116 $newname =~ s/(\[[0-9a-fA-F]{8})/\U$1/; | |
117 $newname =~ s/v([[:digit:].]+)([^\[]+)\[/${2}[v${1}][/i; | |
118 #$newname =~ s/v2 (?=\(.*\) ) \[/ $1 [v2][/; | |
119 $newname =~ s/([^ ])\[DVD\]\[x264\.AAC\]/$1 [DVD]/; | |
120 $newname =~ s/\(DVD\) +\[/[DVD][/; | |
121 $newname =~ s/^(\[[^]]+\])([^ ])/$1 $2/; | |
122 $newname =~ s/(\((1280x720|960x720)[^)]*\))/($2)/; | |
123 $newname =~ s/(\((1920x1080)[^)]*\)) /($2) [BD]/; | |
124 $newname =~ s/\[[^]]*720p[^]]*\] ?/(1280x720) /; | |
125 $newname =~ s/\[[^]]*1080p[^]]*\] ?/(1920x1080) /; | |
126 $newname =~ s/\(720p\)/(1280x720)/; | |
127 $newname =~ s/\[1280x720[^]]+\]/ (1280x720) /; | |
128 $newname =~ s/\([^)]*704x480[^)]*\)//; | |
129 $newname =~ s/([^ ])\(/$1 (/; | |
130 $newname =~ s/\.avi\.avi/.avi/; | |
131 $newname =~ s/^\[([^]&\-]*) +& +([^]&\-]*)\]/[$1-$2]/; | |
132 $newname =~ s/\(704x396 x264 AAC\)//; | |
133 $newname =~ s/\] +\[/][/; | |
134 $newname =~ s/~([^~]+)~/- $1 /; | |
135 $newname =~ s/\[DVD[^]]+\]/[DVD]/; | |
136 $newname =~ s/(\[BD\])+/[BD]/; | |
137 #$newname =~ s/Ep //; | |
138 $newname =~ s/([[:digit:]])v([[:digit:]]) \[/$1 [v$2][/; | |
139 $newname =~ s/([^-]) ([0-9]{2,3}) /$1 - $2 /; | |
140 $newname =~ s/- *\[/ [/; | |
141 $newname =~ s/( ?- )+/ - /g; | |
142 #$newname =~ s/ Special - / Special /; | |
143 $newname =~ s/ (\)|\])/$1/; | |
144 $newname =~ s/(\(|\[) /$1/; | |
145 $newname =~ s/(\(\)|\[\])+//; | |
146 #$newname =~ s/\) +\[/) [BD][/; | |
147 #$newname =~ s/SP/- Special /; | |
148 $newname =~ s/\[(Final|End)\]/[End]/i; | |
149 #$newname =~ s/Gurren Lagann Parallel Works - 2/Gurren Lagann Parallel Works 2/; | |
150 $newname =~ s/ - special - ([[:digit:]]+) / - Special $1 /i; | |
151 $newname =~ s/ memories off - 3\.5 - / Memories Off 3.5 - /i; | |
152 $newname =~ s/ - Navigation - / - Navigation /; | |
153 $newname =~ s/ - Picture Drama - / - Picture Drama /; | |
154 $newname =~ s/\[W B\]/[W_B]/; | |
155 $newname =~ s/ - (Ending|Opening) - 1 / - $1 /; | |
156 $newname =~ s/Seed Character Theater - /SEED - Character Theater /; | |
157 $newname =~ s/ - (Ending|Opening) - ([[:digit:]]+) / - $1 $2 /; | |
158 $newname =~ s/ +/ /g; | |
159 print(qq($_: $newname already exists, skipping\n)) and next() if -e $newname and $_ ne $newname; | |
160 if ($_ eq $newname) { | |
161 print("$_: no need to rename, skipping\n"); | |
162 } else { | |
163 if($skip==1) { print("Result: $_ --> $newname\n"); } | |
164 else { | |
165 if(rename($_, $newname)) { print("$_ -> $newname\n"); } | |
166 else { print("$_: rename failed\n"); } | |
167 } | |
168 } | |
169 next(); | |
170 } | |
171 | |
172 exit(0); |