#!/usr/bin/perl # scan_stuff scans papers # and is released under the terms of the GNU GPL version 3, or any # later version, at your option. See the file README and COPYING for # more information. # Copyright 2014 by Don Armstrong . use warnings; use strict; use Getopt::Long; use Pod::Usage; =head1 NAME scan_stuff - scans papers =head1 SYNOPSIS scan_stuff [options] Options: --simplex single sided --duplex double sided (Default) --mode Scanning mode (Color,Gray,Lineart) --debug, -d debugging level (Default 0) --help, -h display this help --man, -m display manual =head1 OPTIONS =over =item B<--simplex> Single sided documents =item B<--duplex> Double sided documents (default) =item B<--mode> Scanning mode; passed directly to scanimage. Useful options are C (Default), C, and C. =item B<--debug, -d> Debug verbosity. (Default 0) =item B<--help, -h> Display brief usage information. =item B<--man, -m> Display this manual. =back =head1 EXAMPLES scan_stuff; # repeat as necessary scantailor-cli -l 1 --content-detection=cautious *.tif -o out; make_djvu =cut use vars qw($DEBUG); my %options = (device => 'fujitsu', debug => 0, help => 0, man => 0, mode => 'Gray' ); GetOptions(\%options, 'duplex!', 'simplex!', 'mode=s', 'debug|d+','help|h|?','man|m'); pod2usage() if $options{help}; pod2usage({verbose=>2}) if $options{man}; $DEBUG = $options{debug}; my @USAGE_ERRORS; my $use_duplex = 1; if (exists $options{duplex} and exists $options{simplex} and not ($options{duplex} xor $options{simplex})) { push @USAGE_ERRORS,"Conflicting --duplex and --simplex options given"; } pod2usage(join("\n",@USAGE_ERRORS)) if @USAGE_ERRORS; if ((exists $options{duplex} and not $options{duplex}) or (exists $options{simplex} and $options{simplex})) { $use_duplex = 0; } use File::Find; if (@ARGV) { chdir($ARGV[0]); } my $last_num = 0; find(sub { return if /^\./; $File::Find::prune = 1 if -d $_; if (/out_(\d+)_/) { $last_num = $1 if $1 > $last_num; } } ,'.'); $last_num++; exec('scanimage','-d',$options{device}, '--source',$use_duplex?'ADF Duplex':'ADF Front','--mode',$options{mode},'--format','tiff', '--batch=out_'.sprintf('%03d',$last_num).'_%03d.tif'); __END__