Sample Header Ad - 728x90

How to scan with ocr bash script

1 vote
2 answers
666 views
To streamline the scan process I intend to create a script that scans and applies OCR in one step. However my bash skills are rather poor, so I would be very thankful for a bit of help. Here my attempt: #!/bin/bash mydate="$(date +"%Y%m%d-%H%M%S")" image="$(scanimage --device "brother4:net1;dev0" --progress --verbose --resolution=600 -l 0 -t 0 -x 210 -y 297 --format=pdf)" ocrmypdf --deskew "$image" "$mydate".pdf The command, which works well, without creating a date specific filename is: scanimage --device "brother4:net1;dev0" --progress --verbose --resolution=600 -l 0 -t 0 -x 210 -y 297 --format=pdf > scan.pdf && ocrmypdf --deskew scan.pdf scan.pdf Since the OCR process takes some time, the filename containig the time (up to seconds) has to be stored at scantime, and then applied to the final file. Or maybe it is possible -- did not find how -- to pipe the file to ocrmypdf without naming it and then save the file with date and time informations.
Asked by alex (1023 rep)
Apr 26, 2023, 02:16 AM
Last activity: Feb 13, 2024, 09:30 AM