iperka / scan-categorizer

Scan and forget!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

clasp

Scan Categorizer v2 πŸ—ƒ

Script that organizes all PDF files and moves, renames and creates shortcuts dynamically according to predefined categories and file contents. This script can easily be implemented in your current workflows and saves time navigating through Google Drive and enforces directory structures.

Currently, there are two types of conditions that can be applied to each category:

  • or conditions, which require the document to include one of the words defined.
  • and conditions, which require the document to include all the words defined.

The conditions can also be chained and multiple conditions of different types can be applied to one category.

// Don't worry, there is no coding skills required. Just use the UI to generate conditions!
const conditions = [
  {name: 'Lorem', conditions: [and('lorem', 'ipsum')], path: 'Lorem/$y'},
  {name: 'Ipsum', conditions: [or('ipsum', 'dolor')], path: 'Ipsum/$y'},
  {
    name: 'Ipsum',
    conditions: [or('ipsum', 'dolor'), and('lorem', 'ipsum')],
    path: 'Ipsum/$y',
  },
];

If you want to match multiple words you can simply use a RegExp. For example, if you want to match all documents that contain the words Lorem Ipsum, you can use the following RegExp: /lorem ipsum/.

It's important to use a space between the words, otherwise the script will not be able to match the words correctly and bare in mind that default JavaScript RegExp are case sensitive and must be lowercase only.

Table of contents πŸ“š

Getting Started πŸš€

Follow the 7 simple steps in the Installation guide and start configuring your categories. You can even add your code and customize it even more.

Installation πŸ‘Ύ

Step 1 - Create new Script

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.

Step 2 - Add library

In the sidebar menu, click the plus icon on the left-hand side of Libraries.

Screenshot

  • Insert 1489WTMiopg0jt53nfftMhbrHyuF67ieIKOoN2ZCuLLUYNRynw6u6GFS2 as script ID.
  • Select your version. (In most cases, choose the latest version.)
  • Import the library with the name sc.

Step 3 - Configure

Insert the contents from category UI into your Code.gs file. When running the script you get should asked for permission. Grant the required permissions and test the script.

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

Possible use cases πŸ”₯

  • Finally, go digital by scanning and automatically organizing your old papers.
  • Enforce directory structures.
  • Automatically distribute incoming mail.
  • Create shortcuts for each invoice for your taxes.

Migrate 🚧

Thanks for using version 1 already, you're awesome! There are several changes in version 2 that will affect your current configurations.

  • $S argument has been deprecated and can no longer be used.
  • There is no more notification email when documents can't get categorized.
  • When using custom rename functions the addShortcut has also been deprecated.
  • The keywords property has been replaced by conditions.
v1 Syntax v2 Syntax
{
  name: "Lorem",
  keywords: ["Lorem", "Ipsum"],
  path: "Lorem/$y/$m",
}
{
  name: "Lorem",
  conditions: [or("Lorem", "Ipsum")],
  path: "Lorem/$y/$m",
}
{
  name: "Lorem",
  keywords: ["Lorem", "Ipsum"],
  shortcuts: ["Ipsum/$y"]
  path: "Lorem/$y/$m",
}
{
  name: "Lorem",
  conditions: [or("Lorem", "Ipsum")],
  shortcuts: ["Ipsum/$y"] // Still the same
  path: "Lorem/$y/$m",
}

We're sorry if you ran into problems. Please open an Issue if you need help.

API ✨

Functions

sc.categorize(categories: Query.Category[], src: string[]): void

Development 🦺

The repository uses Typescript and transpires and pushes the code to the corresponding Google App Script.

Clone the repository and install the dependencies with yarn install. Keep in mind that by default, every function is hidden by using the namespace technique described by clasp docs. To export a function to the users, simply define a wrapper function inside the index.ts file (See existing for guidance).

Authors πŸ’»

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.

About

Scan and forget!

License:MIT License


Languages

Language:TypeScript 93.7%Language:JavaScript 6.3%