Skip to content

Instantly share code, notes, and snippets.

@ultraist
Created October 28, 2009 04:28
Show Gist options
  • Select an option

  • Save ultraist/220240 to your computer and use it in GitHub Desktop.

Select an option

Save ultraist/220240 to your computer and use it in GitHub Desktop.
# モノクロ画像だけ移動させるコマンド
use strict;
use warnings;
use File::Copy qw/move/;
use File::Spec::Functions qw/catfile/;
my($src_dir, $move_dir) = @ARGV;
unless (defined($src_dir) && defined($move_dir)) {
die "usage $0 src_dir mono_dir\n";
}
unless (-d $src_dir) {
die "$0: $src_dir: $!\n";
}
unless (-d $move_dir) {
mkdir($move_dir);
unless (-d $move_dir) {
die "$0: $move_dir: $!\n";
}
}
opendir(SRC, $src_dir) or die "$0: $src_dir: $!\n";
foreach my $file (readdir(SRC)) {
my $filepath = catfile($src_dir, $file);
if (-f $filepath && $filepath =~ /(\.png$|\.jpg$|\.jpeg$|\.bmp$|\.tiff$)/) {
my $ismono = system("ismono $filepath");
if ($ismono == 0) {
move($filepath, catfile($move_dir, $file));
}
}
}
closedir(SRC);
exit(0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment