- push @all_files, $file;
- print STDERR "$progname: found file $file\n" if ($verbose > 2);
+
+ if ($file =~ m/[~%\#]$/ || # backup file, or
+ ! ($file =~ m/$good_file_re/io)) { # no image extension
+ $skip_count++;
+ print STDERR "$progname: skip file $file\n" if ($verbose > 2);
+ } else {
+ push @all_files, $file;
+ print STDERR "$progname: found file $file\n" if ($verbose > 2);
+ }