Home | Appendix

|  |  | Folder Actions

Folder actions are scripts that you can attach to folders in the Finder. These act on all items you add to these "hot folders." When you add items, the operating system detects the added files and runs any folder actions attached to the folder. The actions supplied by DEVONthink are installed in `~/Library/Scripts/Folder Action Scripts`, and you can add your own scripts to this directory, as needed. For everyday use and exploration, here are the folder action scripts provided by DEVONthink: DEVONthink - Import: Imports files into your databases. DEVONthink - Import & Delete: Imports files into your database, and moves the files to the trash afterwards. DEVONthink - Import to selected group: Imports files to the currently selected group. DEVONthink - Index: Index files to your database, creating links to the original items in the Finder. DEVONthink - Index to selected group: Index files to the currently selected group in your database. PRO DEVONthink - Import, OCR & Delete: Imports files into your database, converts them to searchable PDFs if necessary, and moves the files to the trash afterwards. Attaching a folder action To attach a folder action script to a folder, do the following: Control-click a folder in the Finder. Select Services > Folder Actions Setup from the contextual menu. From the list of available actions, select the folder action script click Attach. Manage folder actions: To manage all your folder actions, Control-click a folder and choose Services > Folder Actions Setup from the contextual menu. Use the Folder Actions Setup utility to see which folders have scripts attached, and to remove folder actions from folders.
Note: If you are running macOS Mojave, you will be prompted to allow the Folder Actions Setup application to run. This notification is controlled by the operating system, not DEVONthink.
Terminology While we can't provide specific training on how to create folder actions, check out Apple's documentation. However, the `on adding folder items to folderVariable after receiving filesVariable` is the handler most commonly used in our folder action scripts. Here is a simple example:
Example: on adding folder items to theFolder after receiving theFiles repeat with thisFile in theFiles tell application id "DNtp" set newRecord to import thisFile to incoming group if exists newRecord then tell application "Finder" to delete thisFile end tell end repeat end adding folder items to
Note: Folder actions, like any computer processes, are treated very literally. When processing files with a folder action, it's best to move or delete the files from the watched folder. This keeps the action from trying to reprocess files.