めどいことはPCにやらせる
書きかけ。まだまだ書き足さないといけない。
#!/usr/bin/perl use strict; use warnings; use version; our $VERSION = qv('0.0.1'); use Digest; use File::Basename qw/fileparse/; use File::Iterator; use File::Spec; use Image::Size qw/imgsize/; use IO::File; use Perl6::Say; my $find = File::Iterator->new( DIR => '.', FILTER => sub { shift =~ m/\.(?:jpe?g|png|gif)$/i }, ); while (my $f = $find->next) { $f = File::Spec->canonpath($f); my $d = Digest->new('SHA-256'); my $fh = IO::File->new($f, '<:raw') or die $!; $d->addfile($fh); my $digest = lc $d->hexdigest; my $suffix = lc +(fileparse $f, qr/(?<=\.)(?i:jpe?g|png|gif)$/)[2]; $suffix eq 'jpeg' and $suffix = 'jpg'; my ($img_x, $img_y) = imgsize $f; my $target = File::Spec->catpath( 'D:\\', File::Spec->catdir('My Pictures', 'sha256', splice @{[split //, $digest]}, 0, 3), "$digest.$suffix" ); # ほげほげする }