#! /usr/bin/perl # # make file list from ``packed'' form # # example: # hogege.r00-12 => hogege.r00, hogege.r01, ..., hogege.r12 # hogege.r00-r12 => hogege.r00, hogege.r01, ..., hogege.r12 # hogee0-12.jpg => hogee0.jpg, hogee1.jpg, ..., hogee12.jpg # hoge00-12.jpg => hoge00.jpg, hoge01.jpg, ..., hoge12.jpg # hoge.aaa-afc => hoge.aaa, hoge.aab, ..., hoge.afc # # TODO: # hoge.r00-r24+rar => hoge.r00, hoge.r01, ..., hoge.r24, hoge.rar # hoge_r00.jpg-r04+rar.jpg => hoge_r00.jpg, ..., hoge_r04.jpg, hoge_rar.jpg # if (@ARGV) { @argv = @ARGV; } else { @argv = ; } foreach (@argv) { chomp; s|^(http://fr\d.idzap.com)/\)d\d\(.*?/http://|$1/http://|; if (/^(.*)\[(|.*\D)(\d+)(|\D.*)[\~\-]\2(\d+)\4\](.*)$/ || /^(.*)(.*)(\d{5})()[\~\-]\2(\d{5})(|\D.*)$/ || /^(.*)(.*)(\d{4})()[\~\-]\2(\d{4})(|\D.*)$/ || /^(.*)(.*)(\d{3})()[\~\-]\2(\d{3})(|\D.*)$/ || /^(.*)(.*)(\d{2})()[\~\-]\2(\d{2})(|\D.*)$/ || /^(.*)(.*)(\d{1})()[\~\-]\2(\d{1})(|\D.*)$/ || /^(.*)(.*)(\d{5})(\D.*)[\~\-]\2(\d{5})\4(.*)$/ || /^(.*)(.*)(\d{4})(\D.*)[\~\-]\2(\d{4})\4(.*)$/ || /^(.*)(.*)(\d{3})(\D.*)[\~\-]\2(\d{3})\4(.*)$/ || /^(.*)(.*)(\d{2})(\D.*)[\~\-]\2(\d{2})\4(.*)$/ || /^(.*)(.*)(\d{1})(\D.*)[\~\-]\2(\d{1})\4(.*)$/ || /^(.*)(|.*\D)(\d{1})(|\D.*)[\~\-]\2(\d+)\4(.*)$/ ) { # print "$1:$2:$3:$4:$5:$6\n"; $head = $1; $pre = $2; $min = $3; $max = $5; $post = $4; $tail = $6; $width = length($min); $i = $min; if ($min > $max) { # die; print "$_\n"; next; } $head .= $pre; $tail = $post . $tail; while ($i <= $max) { printf("%s%.${width}d%s\n", $head, $i, $tail); $i++; } } elsif (/^(.*)\[(|.*\W)(\w+)(|\W.*)[\~\-]\2(\w+)\4\](.*)$/ || /^(.*)(.*)(\w{4})()[\~\-]\2(\w{4})(|\W.*)$/ || /^(.*)(.*)(\w{3})()[\~\-]\2(\w{3})(|\W.*)$/ || /^(.*)(.*)(\w{2})()[\~\-]\2(\w{2})(|\W.*)$/ || /^(.*)(.*)(\w{1})()[\~\-]\2(\w{1})(|\W.*)$/ || /^(.*)(.*)(\w{4})(\W.*)[\~\-]\2(\w{4})\4(.*)$/ || /^(.*)(.*)(\w{3})(\W.*)[\~\-]\2(\w{3})\4(.*)$/ || /^(.*)(.*)(\w{2})(\W.*)[\~\-]\2(\w{2})\4(.*)$/ || /^(.*)(.*)(\w{1})(\W.*)[\~\-]\2(\w{1})\4(.*)$/ ) { $head = $1; $pre = $2; $min = $3; $max = $5; $post = $4; $tail = $6; $width = length($min); $i = $min; if ($min gt $max) { # die; print "$_\n"; next; } $head .= $pre; $tail = $post . $tail; while ($i le $max) { print $head, $i, $tail, "\n"; # $i++ $pos = length($i); while (1) { $pos--; die if ($pos < 0); $c = substr($i, $pos, 1); $c =~ tr/A-Za-z/B-ZAb-za/; substr($i, $pos, 1) = $c; last unless ($c eq "A" || $c eq "a"); } } } else { print "$_\n"; } }