I'm a happy owner of a Brother DCP-9020CDW which has a nice document-feeder feature, allowing you to automatically scan multi page documents (and perfectly integrated with macOSX).

Unfortunately the feeder there is able only to scan a single side of the documents, so when dealing with double-sided documents I usually resorted to macOSX' preview tool and manually rearrange the pages.

That was until yesterday - when I had to scan a 20 page document: enough manual work to justify a script. So feeded2duplex.sh was born.

To use it, simply open the macOSX scanner, and select the following options in the scanner:

scanner options

The scan the document, and scan it again on the backside (that is from the last page).

Then run feeded2duplex.sh providing the file as above and an output file:

$ feeded2duplex.sh input.pdf output.pdf

You can now enjoy your rearranged, double-sided output.pdf :)