scanline – Command-line Document Scanning for Mac OS X

I scan pretty much everything — bills, old photos, mortgage documents, tax stuff, etc. It can be tedious, but it makes finding things much easier when you need to remember whether you filed in 83(b) election in 2006 or what exactly the previous owners disclosed about the condition of the roof.

Having a good scanner with a document feeder helps a lot, but the standard scanning UI in Mac OS X isn’t exactly efficient for quickly scanning a whole bunch of stuff into labeled directories. What I really wanted was a way that I could just type out something quickly on the command line to control the scanner, but I couldn’t find anything out there. So I wrote scanline, which I’m now making available as an MIT-licensed open source project.

Using scanline

The basic way to use scanline is to just invoke it on the command line with no arguments (or hit up-arrow if you just scanned something previously):

airica:~ klep$ scanline

This will scan the current document(s) in the document feeder of the default scanner into ~/Documents/Archive/[year]/scan_[hms].pdf

But there’s a whole lot more you can do. scanline uses directories as labels, so if the document you’re scanning is your auto registration, you can specify that scanline should put it in the “car” directory:

airica:~ klep$ scanline car

This puts the document into ~/Documents/Archive/car/[year]/scan_[hms].pdf

If you also want your registration to show up in your directory for taxes (so you remember to deduct the VLF), you can specify multiple labels:

airica:~ klep$ scanline car taxes

This creates an alias of the scanned document in ~/Documents/Archive/taxes/[year]/scan_[hms].pdf in addition to the original in the car directory.

If it’s a double-sided document (and your scanner supports it), use -duplex to scan both sides:

airica:~ klep$ scanline -duplex car taxes

Want to scan from the flatbed scanner instead of the document feeder?

airica:~ klep$ scanline -flatbed

Want to scan into a different root directory instead of ~/Documents/Archive?

airica:~ klep$ scanline -dir ~/Desktop

Here’s a good one — got lots of items to scan on the flatbed but want them all put together into a single PDF?

airica:~ klep$ scanline -batch -flatbed

Want to name the document something that isn’t generic?

airica:~ klep$ scanline -flatbed -name registration car

The above command will scan the item on the flatbed into ~/Documents/Archive/car/[year]/registration.pdf

If you have multiple scanners connected to your computer, you can select them by name:

airica:~ klep$ scanline -scanner "Epson 565655"

If you’re not sure what scanners are available, list them:

airica:~ klep$ scanline -list

Obtaining scanline

If you’d like to build scanline from source, enhance it, or tweak it for your needs, get it from:

https://github.com/klep/scanline

If you just want the binary (it’s a debug build but plenty fast and stable for real use), you can download it here.

 

How It Works

scanline was created using the ImageCaptureCore framework. It uses Lumberjack for logging and XCTest/OCMock for unit tests. It’s my first Mac app in quite some time, so go easy on me if you look at the source.

 

 

 

 


															

56 Comments

  1. mike
    January 8, 2017

    Big thank you Scott!

    That was exactly the missing part in my home-grown-document-management system. Applescript and the image capture worked, but was too flacky.

    Works great!

  2. Dainius Šileika
    August 22, 2017

    Hello Scott,

    As of last year, every time I scan, scanline either scans twice, or doesn’t scan the first time, I’m forced to press a key again, and then have a double scan.

    Here’s the verbose output:

    %scanline -flatbed -res 300 -v

    https://pastebin.com/5WTs48y5

  3. klep
    August 23, 2017

    Hmm… Are you saying that there’s one document but it has two pages?

  4. John Winfield
    February 26, 2018

    Hi,

    I dowloaded the scanline .dms, binary, how do I install it on a Mac OS X 10.12 El Captain?

    Will scanline work with ScanSnap S1500m?

    Thank you

    John

  5. Oliver
    March 14, 2018

    Just discovered this after getting tired of clicking through UIs and thinking that someone might have already come up with a better solution to mass scanning. Seems to work great with my Brother MFC-7440 and High Sierra. Thank you so much for creating it and releasing it as open source!

Leave a comment

Your email address will not be published. Required fields are marked *