DEVONthink is well known for its automation capabilities and to that end comes with many built-in scripts. Below is a list of the DEVONthink supplied scripts available to you.

## Script menu

This is a list of the pre-installed scripts in DEVONthink's Scripts menu, presented as they appear in the submenus there:

Pro

Chat:

- Create Image Prompt: Generate an Image Diffusion prompt from the key point or selected text in a document.
- Correct Spelling: Correct spelling in a document based on the context of the words.
- Insert Response: Insert an AI response to a question you ask.
- Transform Text: Generate changes to selected text based on your instructions. Some formats, e.g, rich text, support replacing the text.
- Translate Text: Translate selected text to the language in which DEVONthink is running. This does not correct spelling errors.

Comments:

- Append Selected Text: Adds the selected text to the comments of the current document.
- Assemble: Collects the comments of the selected documents and creates a new document listing them.
- Convert to Tags: Converts the tag contained in the comments field to real tags if the comments field of the selected document contains tags separated by commas.
- Speak: Speaks the comments of the selected documents.

Data:

- Move Duplicates to Trash: Moves all duplicates of the selected document to the trash.
- Find & Remove Similar Contents: Finds and removes similar documents.
- Group With Duplicates: Creates a group with duplicates of the selected documents.
- Group With Replicants: Creates a group with replicants of the selected documents.
- Verify & Optimize Databases: Runs a verification on all open databases and optimizes them if they verify successfully. Errors are alerted and logged to Window > Log.
- Check file integrity of databases: Runs a checksum comparison on all items in open databases to check for any discrepancies in the current and stored values. Errors are alerted and logged to Window > Log.

Download:

- Linked Images of Page: Adds linked images of a displayed web page to the database.
- Open Linked Images in Tabs: Opens a document tab for each linked image in a web page viewed in DEVONthink.
- Images of Page: Adds the images of a displayed web page to the database.
- Links of Page: Adds links contained on a displayed web page to the database.
- Download as…: Converts bookmarks to one of these formats: Formatted Notes, HTML Pages, PDF Documents (One Page or Paginated), and Web Archives. There are also versions for creating clutter-free documents as formatted notes, web archives, and PDF documents (One Page and Paginated).

Edit:

- Count Characters: Counts the characters in the current selection.
- Count Words: Counts the words in the current selection.
- Replace text in documents: Enter text to find and replace in plain and rich text documents.

Execute:

- AppleScript: Executes an AppleScript script.
- Perl: Executes a Perl script.
- Shell: Executes a shell script.

Export:

- Listing: Saves a UTF-8 text file containing a text listing of the names of all contents/groups of the current database.
- Daily Backup Archive: Creates a compressed backup (.Zip) of each open databases. All backups are stored in `~/Backup` and their filename includes a datestamp for easy tracking and identification. These can be useful for copying to external media or uploading to a cloud service as a secondary backup strategy. Note: When using this script with an encrypted database, the database will be compressed in an unencrypted state.

Feeds:

- Nature -- Hubble News: Downloads the latest Hubble news.
- iTMS -- Added Albums: Downloads covers of albums recently added to the iTunes Music Store.

Format:

- Body Normal: Formats selected text as "Body Normal".
- Body Small: Formats selected text as "Body Small".
- Header Capitalized: Formats selected text as "Header Capitalized".
- Header Main: Formats selected text as "Header Main".
- Header Secondary: Formats selected text as "Header Secondary".
- Remove Attachments: Removes attachments from RTFD files.
- Remove Links: Removes linked text from the contents of a selected rich text document.
- Source: Formats selected text as "Source".
- Reset Spacing: Resets the line and paragraph spacing of selected rich text.

Images:

- Copy Info to Comment: Copies basic image info to the comment field.
- Flip Horizontal / Vertical: Flips the image horizontally/vertically.
- Rotate Left / Right: Rotates the image left/right.
- Landscape to Portrait: Rotates only landscape images to portrait.
- Portrait to Landscape: Rotates only portrait images to landscape.
- Scale to 1024 pixels: Scales the image to 1,024 pixels.
- Scale to 200%: Scales the image to 200 percent.
- Scale to 50%: Scales the image to 50 percent.

Import:

- Man Page: Imports a UNIX manual page as a plain text document.
- Perldoc: Imports the documentation of Perl pages, modules, functions, or programs.

Reminders:

- Add as Event to Calendar: Adds a new event to Calendar linking back to the selected item in DEVONthink.
- Add as To Do to OmniFocus: Adds the selected item as a to-do item to OmniFocus.
- Add as To Do to Reminders: Adds the selected item as a to-do item to Reminders.
- Add as To Do to Things: Adds the selected item as a to-do item to Things.

Note: These are scripts for integrating with external applications. For scripting internal reminder scripts, see the Reminder Scripts section of the chapter about automation.

Rename:

- Append Selected Text: Appends the selected text to the title of the currently selected item.
- Change Case: Change the case of selected text to titlecase.
- Replace Text: Replaces a text passage in the titles of selected documents.
- To Webpage Title: Sets the titles of the selected documents to the names of the web pages pointed to by their URL fields.
- To Subject: Sets the titles of the selected documents to the subject lines of the email messages if the selected documents are email messages.

Sheets:

- Add Multiple Records: Adds up to 999 empty records to a sheet.
- Column Sum & Mean Value: Calculates the sum and average of a table column.
- Row Sum & Mean Value: Calculates the sum and average of a table row.
- Check sums in last column: Checks the sums in the last column on validity.

Tabs:

- Open Bing: Open a new tab for the Bing search engine.
- Open Google: Open a new tab for the Google search engine.
- Open Location: Open a new tab for a location you specify.

Note: The last script does no URL validation, though DEVONthink's dictionary makes it possible to script this too.

Thumbnails:

- Flip Horizontal / Vertical: Flips the thumbnails of selected documents horizontally or vertically.
- Rotate Left / Right: Rotates the thumbnails of selected documents left or right.
- Landscape to Portrait: Rotates landscape thumbnails to portrait.
- Portrait to Landscape: Rotates portrait thumbnails to landscape.

Note: While these scripts work with all image formats including PDF, they should not be used for PDF documents. They will only work on the first page of the PDF and destroy all embedded metadata.

## Smart Item Scripts

These are scripts available to smart items, i.e., smart rules and batch processing. They are divided by the two available actions: `Apply Script` and `Script with Input/Output`.

Apply Script:

- Add Favicons: Attempts to apply the favicon for a web-based document, e.g., a bookmark.
- Add Web Page Image: Attempts to apply a web page's image as the document's thumbnail.
- Close All Databases: Closes all open databases except the Global Inbox.
- Close All Documents: Closes all document windows.
- File Items Using @Destination in Name: If a filename is suffixed with @ followed by a group name, it will be used to file the document into a matching group. For example, a document named `Marriott stay@Expenses` would be filed in an "Expenses" group. If a group isn't found, it will be created in the Inbox of the parent database.
- Reminders - Next Week: Set a reminder for a week from the current time and date.
- Reminders - Remove: Remove an applied reminder from the matched item(s).
- Reminders - Tomorrow: Set a reminder for the same time tomorrow.
- Tags - Add Most Important Words: Adds the top five words from the concordance of the document. Assessed by weight.

Pro

- Assign Document Date & Amount: Adds a detected date and amount to the document as custom metadata.
- Downloads - Add Embedded Images: Add embedded images in a web-based file to the Download Manager. Used with HTML-based files, e.g., web archives, etc.
- Downloads - Add Linked Images: Add linked images to the Download Manager. Used with HTML-based files, e.g., web archives, etc.
- Downloads - Add Podcasts: Add detected podcast links to the Download Manager. Used with podcast RSS feeds containing download links.
- Download Bibliographic Metadata: Attempts to retrieve the digital object identifier (DOI) of the document and set the title and metadata.

Script with Input/Output:

- Annotation - Append Text: Gets text from a `Set Script Input` action and either creates an annotation file with the text or appends it to an existing one.
- Annotation - Get Text: Gets the text from an existing annotation file, if one exists.
- Checksum: Returns the content hash for the record.
- Coordinates: Returns the latitude and longitude from the geolocation data on the item.
- Daily Quote: Gets a random daily quote from an English and a German site.
- Image Size: Returns the width and height of an image.
- Latest News: Returns a random headline from the New York Times or Tagesschau.
- Name - First Number: Returns the first number in a record's name.
- Name - Last Number: Returns the last number in a record's name.
- Text - Lowercase/Uppercase: Returns the text of a Set Script Input placeholder to lower or uppercase.
- Text - Random String: Returns a 16 character string of random letters and numbers.
- Web Page - Description: Returns the description from the metadata of a web page, if available.
- Web Page - Keywords: Returns the keywords from the metadata of a web page, if available.
- Zettel-ID: Queries Markdown metadata and returns the value for a `Zettel-ID` attribute.

You can read more about how to use these scripts in the Smart Rules and Batch Processing section of this manual.