Dynamic autotags (autotag name and notes can be calculated from data)
This is a more advanced feature. Most of the time, autotags have a predefined name, so you say application Word is part of autotag Work documents. But what if you want to add the name of the document to the autotag? Do we need to create a new autotag for each document?
(For a simpler version of this, take a look at Append rules data setting in Autotag editor.)
Let’s take a look at a more complicated example. Let’s say you use Excel and Word when you work for your clients. Let’s also say you save the documents in folders by client and project, like so:
C:\Client 1\Project 1\some docs...
C:\Client 1\Project 2\some docs...
C:\Client 2\Project 3\some docs...
C:\Client 2\Project 4\some docs...
Lets try to create a simple autotag. Lets tag all Word and Excel usage as "Work" and lets add document we were working on to Notes. How do we do this?
First we are going to filter Document timeline so only documents from the mentioned folders show up. You can do this by typing c:\work to filter.
You can use this filter to create autotag. Click on the arrow facing down on the right side and choose Add to autotag. For autotag write "Work" and for the notes use a special keyword {{title}}. This will insert any title which was matched by the rule.
So after we do this our autotags are:
Autotag: "Work", Notes: "C:\work\Client 1\Project 1\some doc.docx"
...
We used {{title}} to insert document name to notes. The other reserved keyword is {{group}}. To understand the difference take a look at the Day view. Below the timelines on the left are details about activities, on the right are summaries. So for example on Applications timeline on the left are window titles, on the right is the application to which the titles belong.
So {{title}} will take the value on the left, while {{group}} will use the value on the right. You can use both keywords in Notes or in name of autotag.
We accomplished something, but we can make it better. Since we store documents based on client and project, wouldn’t it be great if we could use this for our autotags, so we would get something like
Autotag: "Work, Client 1, Project 1", Notes: "filename"
Regular expressions in AutoTags
ManicTime supports regular expressions and we can use them to parse the filename. To write regex you need to enclose it in #”regex”. So in our example we will use
#"C:\\work\\([^\\]*)\\([^\\]*)\\(.*)"
I wont go into much details about regular expressions, you can read more about them here.
In short, there are three capturing groups inside the regex, which we can use in our autotag as {{1}}, {{2}}, {{3}}
So now we get what we set out to do.
Lets do one more thing, lets say we want to know which application those docs were created with, was it Excel or Word? We will use Append tag for this. Right click Word on Apps timeline, choose Add to autotag and type Word. Then do the same for Excel. In the Autotag editor select Word autotag, choose Edit and on Advanced tab choose Append and apply to selected and choose "Work, {{1}}, {{2}}".
Then do the same for Excel, once you’re done you’ll get this.
So now you know for which client and project you were working, in which app you were working and also which document.