Created
October 28, 2009 04:28
-
-
Save ultraist/220240 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # モノクロ画像だけ移動させるコマンド | |
| 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