-
Notifications
You must be signed in to change notification settings - Fork 12
Rules
As you see from the sample configuration file above, you can define multiple rules. Each rule must follow a certain format so that it will be properly parsed.
:rules:
-
description: Rule #1
scope: content
condition: My Condition
tags: tag1 tag2
destination: Inbox
service: evernote
title: '<match> Statement <date=%Y-%m>'
- Begin the rules definition with the
:rules:
declaration. - Each new rule after much start the a
-
. Important: there needs to be a space before the dash. - Then you simply list out all of the rule fields. The only required fields for a rule are
description
,scope
andcondition
You do not need to define a particular field if it does not pertain to that rule. You can also leave the value for a field blank and it is essentially the same as omitting it for the rule.
The rules are processed in the order that they are defined. When a rule is matched and applies a value to a particular field, the field becomes locked. No other rule can now apply changes to field.
Tags are an exception. Since you can have as many tags as you want on a document, if multiple rules match a document, the tags from each rule will be applied to the document.
Let's look at a simple example.
:rules:
-
description: Rule #1 - BofA Statements
scope: content
condition: Bank of America
tags: bank financial
destination: 'Bank Statements'
title: 'BofA Statement <date=%Y-%m>'
-
description: Rule #2 - Joe Stuff
scope: content
condition: Joe Workman
tags: joe
destination: Personal
Let's say that I have just scanned in my last bank statement and it matches both of the rules defined above. The tags defined from both rules will be applied. The destination from Rule #1 will win. The title from Rule #1 will be applied as well (more on the cool <date>
variable later. If a title had been set in Rule #2, it still would not have gotten applied though. This is what the final outcome will be.
tags: bank financial joe
destination: 'Bank Statements'
title: 'BofA Statement <date=%Y-%m>'
Here is an overview of each of the available fields for a rule.
Note: One precaution is that if you want to use special characters such as @
, %
or spaces, you will need to surround that text in quotes.
-
description:
This field is solely used for future you… so that you remember what a particular rule is used for.
-
scope:
This defines the scope that the condition will be evaluated against. The following scopes are supported. A rule can have multiple values for scope defined. Ex:
scope: content filename
-
filename
The condition will be evaluated against the name of the file, excluding the extension. -
content
The condition will be evaluated against the contents of the document.
Use the
--prompt
option to manually manipulate the filename via a dialog box before it gets processed through the rules.If the document is a PDF, you will need to ensure that it has gone through OCR.
-
-
condition:
This is the text that you would like to match upon for your rule. Conditions fully supports regular expressions. This allows you to get pretty clever with your matches. However, all conditions are set to be case insensitive. You can then referenced the matched text with the
<match>
special variable within other rule fields.Testing your Regex: Patterns and Rubular are both nice tools for testing your regular expressions. I use Patterns daily!
-
tags:
This is a space delimited list of tags that will be added document. For file based services like Finder and DevonThink, openmeta tags will be applied to the file. Evernote's tag system will be used for those notes.
-
title:
This is the title of the note. For file based services like Finder and DevonThink, this will be the new name of the file. For Evernote, it will be the title of the note.
-
destination:
This will override the global destination setting described in the Global Options section. All the same standards from the global setting applies here as well.
-
service:
This will override the global service setting described in the Global Options section. All the same options from the global setting applies here as well.
There is a special rule that kicks off the analyzing of a document for the first instance of a date. This rule can be anywhere in the rules list, however, I recommend you just add it to the top if you want this feature.
-
description: Date Rule
scope: content
condition: <date>
If this rule is not apart of the rule set, then default_date setting will be used instead.
The following basic date formats (and many derivatives of them) are searched for in the below order. The first string that matches will be used as the date.
- 12/29/2012
- December 29, 2012
- 29 December 2012
- December 2012
NOTE: It is possible that a string that was not intended to be a date will be processed as the discovered date. This should only be a minute percentage though.
Where used, the <match>
variable will be replaced the entire string that the condition matched. This can be utilized with any of the supported rule fields: destination
, title
, service
and tags
Where used, the <date>
variable will be replaced the discovered date. If a date was not found inside the document, then the date_default
setting will be used. The format for this date is configured in the date_format
.
You can override the the default format by adding it within the date variable like <date=%Y-%m>
. In this example the date format will be set to %Y-%m instead of what is set in the date_default setting.
When you use the variable <filename>
the original name of the file will be inserted. This could be helpful if you simply want to add to the file name or use the name of the file in the title of your note and still add more data such as a date.
When you are using the Finder service, you can set the destination to <nomove>
this will keep the file in the folder that it is already in. However, based on the rules, the file name be renamed.