I use script for ocr (non ocr) pdf file. The script makes 1) keep original file 2) save new file (OCR) with the name ORIGINALNAME_ocr.pdf. Script is below.
My wish is have folder on desktop and immediately if I copy pdf file to this folder, pdf will be ocr like the script makes - keep original file 2) save new file originalname_ocr.pdf. BUT If there is originalname.pdf and originalname_ocr.pdf script will do nothing.
How I can set it please?
on performSmartRule(theRecords)
tellapplicationid “DNtp”
try
show progress indicator “OCR” cancel button 1 steps countof theRecords
repeatwith theRecord in theRecords
if cancelled progress thenerror number -128
step progress indicator (name of theRecord) asstring
set theFile to path of theRecord
set newName to name of theRecord
set newName to newName
set newFile toocr file theFile to parent 1 of theRecord type PDF document
Please use three backticks before an after your code like so
``` code goes here
```
That makes sure it is highlighted correctly, can be copy/pasted and possibly directly run in Script Editor.
Also, your question (or variants of it) has been asked very, very often here (and answered, too). I suggest you use the search function here and check the corresponding threads.
As to your code: It is advisable to reduce it to the bare minimum – that makes it faster to read and easier to understand. So, a progress indicator is nice, but distracting from the main task. The same holds for the try block, and set newName to newName is irritating.
Personally, I don’t see the point in keeping the non-OCR file and fiddling around with all these naming conventions. It seems overly complicated to me – if you absolutely need to keep the original, just set a tag on it after OCR’ing and skip all files where this tag is set in your script or smart rule.
I receive a lot of non ocr pdf file thru day. I need to ocr it and copy together with original (non ocr) file to special folder of every project.
Now I copy every file to folder - start smart rule with script and copy to special folder. My idea is copy all non ocr file to one folder - the script should ocr it automatically - and in the end of workday I could copy everything to special folders = saving time