# Immediately ocr pdf file after copy to folder

**URL:** <https://discourse.devontechnologies.com/t/immediately-ocr-pdf-file-after-copy-to-folder/75620>\
**Category:** DEVONthink\
**Tags:** automation, devonthink3\
**Created:** [May 4, 2023, 9:09pm UTC](https://discourse.devontechnologies.com/t/immediately-ocr-pdf-file-after-copy-to-folder/75620 "2023-05-04T21:09:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sonicx29](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/s/71e660/32.png) [@Sonicx29](https://discourse.devontechnologies.com/u/Sonicx29)\
**Post date:** [May 4, 2023, 9:09pm UTC](https://discourse.devontechnologies.com/t/immediately-ocr-pdf-file-after-copy-to-folder/75620/1 "2023-05-04T21:09:37Z")

</div>

Hello,

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)

**tell** _application_ _id_ “DNtp”

**try**

**show progress indicator** “OCR” cancel button 1 steps **count**  **of** theRecords

**repeat**  **with** theRecord **in** theRecords

**if** cancelled progress **then**  **error** number -128

**step progress indicator** (name **of** theRecord) **as** _string_

**set** theFile **to** path **of** theRecord

**set** newName **to** name **of** theRecord

**set** newName **to** newName

**set** newFile **to**  **ocr** file theFile to _parent_ 1 **of** theRecord type _PDF document_

**set** name **of** newFile **to** newName

**end**  **repeat**

**on**  **error** error\_message number error\_number

**hide progress indicator**

**if**  **the** error\_number **is**  **not** -128 **then**  **display alert** “DEVONthink” message error\_message as _warning_

**end**  **try**

**hide progress indicator**

**end**  **tell**

**end** performSmartRule

---

<div class="post-metadata">

**Author:** ![chrillek](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/chrillek/32/29340_2.png) [@chrillek](https://discourse.devontechnologies.com/u/chrillek)\
**Post date:** [May 4, 2023, 9:23pm UTC](https://discourse.devontechnologies.com/t/immediately-ocr-pdf-file-after-copy-to-folder/75620/2 "2023-05-04T21:23:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![BLUEFROG](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/bluefrog/32/135_2.png) [@BLUEFROG](https://discourse.devontechnologies.com/u/BLUEFROG)\
**Post date:** [May 4, 2023, 9:48pm UTC](https://discourse.devontechnologies.com/t/immediately-ocr-pdf-file-after-copy-to-folder/75620/3 "2023-05-04T21:48:27Z")

</div>

While your attempt is admirable, this is not the advocated approach. See…

> **[DEVONtechnologies | How to Install the Import & OCR Rule](https://www.devontechnologies.com/blog/20221115-import-and-ocr-smart-rule)**
>
> DEVONtechnologies develops DEVONthink, DEVONagent, and other Mac and iOS apps for document and information management and web research.

---

<div class="post-metadata">

**Author:** ![Sonicx29](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/s/71e660/32.png) [@Sonicx29](https://discourse.devontechnologies.com/u/Sonicx29)\
**Post date:** [May 4, 2023, 9:51pm UTC](https://discourse.devontechnologies.com/t/immediately-ocr-pdf-file-after-copy-to-folder/75620/4 "2023-05-04T21:51:15Z")

</div>

My needs are:

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 🙂

---

<div class="post-metadata">

**Author:** ![cgrunenberg](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/cgrunenberg/32/7172_2.png) [@cgrunenberg](https://discourse.devontechnologies.com/u/cgrunenberg)\
**Post date:** [May 5, 2023, 5:44am UTC](https://discourse.devontechnologies.com/t/immediately-ocr-pdf-file-after-copy-to-folder/75620/5 "2023-05-05T05:44:45Z")

</div>

> [@Sonicx29](#):
>
> **set** newFile **to**  **ocr** file theFile to _parent_ 1 **of** theRecord type _PDF document_

Usage of `parent 1` as a destination is actually discouraged, the recently added `location group` property is recommended instead.

---

<div class="post-metadata">

**Author:** ![system](https://devontech-discourse.s3.dualstack.us-east-1.amazonaws.com/uploads/original/2X/4/4e6ff70c96be2eb307a274d890bba8d71ba671b3.png) [@system](https://discourse.devontechnologies.com/u/system)\
**Post date:** [May 4, 2026, 5:44am UTC](https://discourse.devontechnologies.com/t/immediately-ocr-pdf-file-after-copy-to-folder/75620/6 "2026-05-04T05:44:52Z")

</div>

This topic was automatically closed 1095 days after the last reply. New replies are no longer allowed.
