/
Auto OCR pending.applescript
55 lines (43 loc) · 1.79 KB
/
Auto OCR pending.applescript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
on performSmartRule(theRecords)
tell application id "DNtp"
set ib to inbox
repeat with theRecord in theRecords
do shell script "mkdir -p /tmp/abbyy/"
do shell script "mkdir -p /tmp/abbyy/mrc/"
set itemPath to path of theRecord
set itemName to name of theRecord
set pdfPath to "/tmp/abbyy/" & itemName & ".pdf"
set pdfMRCPath to "/tmp/abbyy/mrc/" & itemName & ".pdf"
tell application "FineReader"
repeat while is busy
delay 1
end repeat
--- create normal pdf file
export to pdf pdfPath from file itemPath image quality high quality ocr languages enum [Japanese, English]
repeat while is busy
delay 1
end repeat
end tell
--- import normal pdf file
set newRecord to import pdfPath to ib
tell newRecord
set tags to text items of ["ocr_done"]
end tell
tell application "FineReader"
repeat while is busy
delay 1
end repeat
--- create mrc pdf file
export to pdf pdfMRCPath from file itemPath image quality high quality ocr languages enum [Japanese, English] with use mrc
repeat while is busy
delay 1
end repeat
end tell
--- import mrc pdf file
set newRecord to import pdfMRCPath to ib
tell newRecord
set tags to text items of ["ocr_done", "mrc"]
end tell
end repeat
end tell
end performSmartRule