Skip to content

Scan Categorizer v1.2.2 🏸

Compare
Choose a tag to compare
@michaelbeutler michaelbeutler released this 07 Jun 14:18
· 20 commits to main since this release
6fd8ba0

Google Script for better scan workflow. This script allows you to categorize scanned documents with predefined categories and organize your Drive.
The script uses OCR to check if one or more of the given keywords are included in the document and if only one category is matched it will organize according to configuration.

Table of Contents 🧾

Installation 🎈

Create a new Google Script Project within your Google Account. (If App Script is not enabled for your account ask your administrator or switch the account.) When created the project should open an editor. Edit the Code.gs and paste the script you downloaded.

Add the Drive and Gmail services to the project and hit Run. The script should ask for permission. Grant the required permissions and test the script.

It's recommended to test your configuration before creating a Trigger.

Configuration βš™

Adjust the values to your needs.

SCAN_FOLDER_ID

The script will only handle PDFs inside the given folder. Define your input folder.

const SCAN_FOLDER_ID = "1ZNbdXdDdOd-djdedxd9dod1dLdrdwdFd";

REPORT_EMAIL

Whenever a document can't be categorized due to missing keywords or more than one matched category, you will get notified via email.

const REPORT_EMAIL = "your-email@example.com";

CATEGORIES

This option defines the categories. Every PDF document that includes one or more of the defined keywords will be matched and will apply the category. The rename property is optional and can be used to rename the name of the document as required. The extension must be included and must always return a filename or throw an Error.

const CATEGORIES = [
  {
    name: "Foo Bar",
    keywords: ["foo", "bar"],
    path: "Foo/Bar/$y/$m",
    rename: function (document) {
      // File ID
      Logger.log(document.id);

      // Current Filename
      Logger.log(document.name);

      // Text contents
      Logger.log(document.text);

      // Creation date
      Logger.log(document.date);

      // Return new filename
      return "new filename";
    },
  },
];

Usage πŸš€

Be sure to configure the script accordingly before using it.

  • Scan a document with your scanner or favorite scanner app. (SwiftScan recommended)
  • Upload your PDF document to Google Drive into the defined Scanner folder.
  • Manually or automatically trigger script and all the documents will get categorized and organized.

Authors πŸ‘¨β€πŸ’»

License πŸ“ƒ

MIT

Contributing 🀝

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate and meet the quality gate requirements.