-
-
Save laysakura/9542556 to your computer and use it in GitHub Desktop.
ScanSnap S1500
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
| #!/bin/sh | |
| ## Scan documents with ScanSnap 1500S. | |
| ## | |
| ## (1) Set documents to ScanSnap | |
| ## (2) Run this command | |
| ## | |
| ## This file is uploaded to gist: | |
| ## https://gist.github.com/9542556 | |
| # Parse command line options | |
| USAGE="Usage: `basename $0` [-c color (Gray|Color)] [-p paper size (A4|A5|B4|B5)] [-x x size (mm) -y y size (mm)] [-h]" | |
| while getopts c:p:h OPT; do | |
| case "$OPT" in | |
| c) | |
| color=$OPTARG | |
| ;; | |
| p) | |
| papersize=$OPTARG | |
| case $papersize in | |
| A4) | |
| x_mm=210 | |
| y_mm=297 | |
| ;; | |
| A5) | |
| x_mm=148 | |
| y_mm=210 | |
| ;; | |
| B4) | |
| x_mm=257 | |
| y_mm=364 | |
| ;; | |
| B5) | |
| x_mm=182 | |
| y_mm=257 | |
| ;; | |
| B6) | |
| x_mm=128 | |
| y_mm=182 | |
| ;; | |
| *) | |
| echo "Paper size `$papersize` is unsupported." | |
| exit 2 | |
| ;; | |
| esac | |
| ;; | |
| h) | |
| echo $USAGE | |
| exit 0 | |
| ;; | |
| *) | |
| echo $USAGE | |
| exit 1 | |
| ;; | |
| esac | |
| done | |
| if [ -z $y_mm ]; then | |
| echo $USAGE | |
| exit 1 | |
| fi | |
| if [ -z $color ]; then | |
| color="Gray" | |
| fi | |
| # Temporary directory | |
| now=`date +'%Y-%m-%d--%H-%M-%S'` | |
| tmpdir="./myscan-$now" | |
| mkdir -p $tmpdir | |
| # Echo options | |
| echo "Paper size: $x_mm mm x $y_mm mm" | |
| echo "Scan color: $color" | |
| echo "Working direcory: $tmpdir" | |
| echo | |
| # Start scanning | |
| curdir=`pwd` | |
| cd $tmpdir | |
| sudo scanimage \ | |
| --mode $color \ | |
| --resolution 150 \ | |
| --page-height $y_mm \ | |
| --source "ADF Duplex" \ | |
| -b \ | |
| cd $curdir | |
| # Finish | |
| cat <<EOF | |
| Use the following command to get PDF. | |
| # Scan the cover page | |
| sudo scanimage --mode Color --resolution 150 --page-height $y_mm --source "ADF" | |
| # Get the PDF | |
| convert *.pnm $tmpdir/*.pnm TITLE.pdf | |
| EOF | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment