# Smart Rule to add date to filename doesn't always work

**URL:** https://discourse.devontechnologies.com/t/smart-rule-to-add-date-to-filename-doesnt-always-work/69225
**Category:** Automation
**Created:** [January 26, 2022, 6:09pm UTC](https://discourse.devontechnologies.com/t/smart-rule-to-add-date-to-filename-doesnt-always-work/69225 "2022-01-26T18:09:54Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![amalis](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/amalis/32/10548_2.png) [@amalis](https://discourse.devontechnologies.com/u/amalis)
#### Post date: [January 26, 2022, 6:09pm UTC](https://discourse.devontechnologies.com/t/smart-rule-to-add-date-to-filename-doesnt-always-work/69225/1 "2022-01-26T18:09:54Z")

</div>

I have a very simple smart rule to add a document date to a filename:

![Rule](https://devontech-discourse.s3.dualstack.us-east-1.amazonaws.com/uploads/original/3X/1/4/145f7462a2b3735feb0f3ebc802e981e15b02d03.jpeg)

Most of the time, it works great and adds the date detected in the document to the beginning of the file name, for example “Receipt.pdf” will become “2022-01-20 Receipt.pdf”, assuming that the date 1/20/2022 is somewhere in the receipt.

However, I often print out emails from the Gmail web client directly into DT (Pro 3.8), which look like this:

 ![Example](https://devontech-discourse.s3.dualstack.us-east-1.amazonaws.com/uploads/original/3X/d/4/d40065aa33d6424fcf72befddb9436634311323c.png)

Invariably, DT cannot detect the date in these emails, and when I try to use the smart rule on, for example, “Test email.pdf”, the filename doesn’t change.

Can the date recognition be improved for such files?

Thanks,  
Andy

---

<div class="post-metadata">

### Author: ![BLUEFROG](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/bluefrog/32/135_2.png) [@BLUEFROG](https://discourse.devontechnologies.com/u/BLUEFROG)
#### Post date: [January 26, 2022, 6:13pm UTC](https://discourse.devontechnologies.com/t/smart-rule-to-add-date-to-filename-doesnt-always-work/69225/2 "2022-01-26T18:13:19Z")

</div>

Note:

**All Databases** as a search target and **Size is not 0** is a **very** dangerous combination.  
You should be **much, much** more specific in the target and criteria you apply.

And even if this is just using the **On Demand** event trigger, you should get in the habit of more safe constructions in smart rules.

* * *

What browser are you printing out of?

---

<div class="post-metadata">

### Author: ![amalis](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/amalis/32/10548_2.png) [@amalis](https://discourse.devontechnologies.com/u/amalis)
#### Post date: [January 26, 2022, 6:14pm UTC](https://discourse.devontechnologies.com/t/smart-rule-to-add-date-to-filename-doesnt-always-work/69225/3 "2022-01-26T18:14:35Z")

</div>

Safari in this case.

Do you have a recommendation for how I should change the search target predicate?

Thanks,  
Andy

---

<div class="post-metadata">

### Author: ![BLUEFROG](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/bluefrog/32/135_2.png) [@BLUEFROG](https://discourse.devontechnologies.com/u/BLUEFROG)
#### Post date: [January 26, 2022, 6:18pm UTC](https://discourse.devontechnologies.com/t/smart-rule-to-add-date-to-filename-doesnt-always-work/69225/4 "2022-01-26T18:18:15Z")

</div>

Here is an example of the test smart rule I just made…

 ![image](https://devontech-discourse.s3.dualstack.us-east-1.amazonaws.com/uploads/original/3X/0/7/0736c9bd71922b2c0cbaddb409b453dd49e6fd71.jpeg)

Note it’s a specific Inbox of a specific database, looking only for PDFs with words in them.

I also just printed a PDF from Safari to this Inbox and it changed the name as expected.  
What OS are you running?

---

<div class="post-metadata">

### Author: ![amalis](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/amalis/32/10548_2.png) [@amalis](https://discourse.devontechnologies.com/u/amalis)
#### Post date: [January 26, 2022, 6:21pm UTC](https://discourse.devontechnologies.com/t/smart-rule-to-add-date-to-filename-doesnt-always-work/69225/5 "2022-01-26T18:21:56Z")

</div>

Big Sur 11.6.2. I don’t yet trust Monterey. 🙂

---

<div class="post-metadata">

### Author: ![amalis](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/amalis/32/10548_2.png) [@amalis](https://discourse.devontechnologies.com/u/amalis)
#### Post date: [January 26, 2022, 6:23pm UTC](https://discourse.devontechnologies.com/t/smart-rule-to-add-date-to-filename-doesnt-always-work/69225/6 "2022-01-26T18:23:27Z")

</div>

I just made that change you indicated. I still get the same results, it works on most files, but not the email in question.

---

<div class="post-metadata">

### Author: ![BLUEFROG](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/bluefrog/32/135_2.png) [@BLUEFROG](https://discourse.devontechnologies.com/u/BLUEFROG)
#### Post date: [January 26, 2022, 6:25pm UTC](https://discourse.devontechnologies.com/t/smart-rule-to-add-date-to-filename-doesnt-always-work/69225/7 "2022-01-26T18:25:27Z")

</div>

Does it work on other emails you print from Safari?

---

<div class="post-metadata">

### Author: ![amalis](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/amalis/32/10548_2.png) [@amalis](https://discourse.devontechnologies.com/u/amalis)
#### Post date: [January 26, 2022, 6:28pm UTC](https://discourse.devontechnologies.com/t/smart-rule-to-add-date-to-filename-doesnt-always-work/69225/8 "2022-01-26T18:28:58Z")

</div>

In most cases, when I print an email, I end up having to add the date manually. It’s an annoyance. If I tell Safari to include the headers and footers, then it can pick up the date from there with no problem. Maybe I’ll just to that going forward. But it’s a mystery, I thought it’s perhaps a result of the use of the three letter abbreviation for the month.

---

<div class="post-metadata">

### Author: ![BLUEFROG](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/bluefrog/32/135_2.png) [@BLUEFROG](https://discourse.devontechnologies.com/u/BLUEFROG)
#### Post date: [January 26, 2022, 9:36pm UTC](https://discourse.devontechnologies.com/t/smart-rule-to-add-date-to-filename-doesnt-always-work/69225/9 "2022-01-26T21:36:22Z")

</div>

Ugh! I so detest mail in a browser 😕

I just ran another test with no headers and footers. It detected the date and renamed as expected.

 ![Screen Shot 2022-01-26 at 04.34.10 PM](https://devontech-discourse.s3.dualstack.us-east-1.amazonaws.com/uploads/original/3X/4/c/4c408906e97ffd046ffefc0f68922c707b00d35a.jpeg)

Stay tuned for the next release.

---

<div class="post-metadata">

### Author: ![chrillek](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/chrillek/32/29340_2.png) [@chrillek](https://discourse.devontechnologies.com/u/chrillek)
#### Post date: [January 26, 2022, 9:38pm UTC](https://discourse.devontechnologies.com/t/smart-rule-to-add-date-to-filename-doesnt-always-work/69225/10 "2022-01-26T21:38:50Z")

</div>

\_is \_ there a date anywhere in the text of the email? If not, how could DT possibly find a date without having recourse to the headers?

---

<div class="post-metadata">

### Author: ![amalis](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/amalis/32/10548_2.png) [@amalis](https://discourse.devontechnologies.com/u/amalis)
#### Post date: [January 26, 2022, 9:47pm UTC](https://discourse.devontechnologies.com/t/smart-rule-to-add-date-to-filename-doesnt-always-work/69225/11 "2022-01-26T21:47:25Z")

</div>

Thanks!

---

<div class="post-metadata">

### Author: ![amalis](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/amalis/32/10548_2.png) [@amalis](https://discourse.devontechnologies.com/u/amalis)
#### Post date: [January 26, 2022, 9:48pm UTC](https://discourse.devontechnologies.com/t/smart-rule-to-add-date-to-filename-doesnt-always-work/69225/12 "2022-01-26T21:48:15Z")

</div>

@chrillek The date is in the upper right of the printed email.

---

<div class="post-metadata">

### Author: ![cgrunenberg](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/cgrunenberg/32/7172_2.png) [@cgrunenberg](https://discourse.devontechnologies.com/u/cgrunenberg)
#### Post date: [January 27, 2022, 7:19am UTC](https://discourse.devontechnologies.com/t/smart-rule-to-add-date-to-filename-doesnt-always-work/69225/13 "2022-01-27T07:19:09Z")

</div>

> [@amalis](#):
>
> The date is in the upper right of the printed email.

Could you send a not working PDF document to cgrunenberg - at - [devon-technologies.com](http://devon-technologies.com)? Thank you!

---

<div class="post-metadata">

### Author: ![Blanc](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/blanc/32/8008_2.png) [@Blanc](https://discourse.devontechnologies.com/u/Blanc)
#### Post date: [January 27, 2022, 10:58am UTC](https://discourse.devontechnologies.com/t/smart-rule-to-add-date-to-filename-doesnt-always-work/69225/14 "2022-01-27T10:58:19Z")

</div>

> [@amalis](#):
>
> The date is in the upper right of the printed email

Can you copy and paste the date from the PDF? @cgrunenberg could regional/language settings in macOS influence whether DT recognises the “day\_verbose, month\_verbose day\_numeric, year\_numeric” pattern?

---

<div class="post-metadata">

### Author: ![cgrunenberg](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/cgrunenberg/32/7172_2.png) [@cgrunenberg](https://discourse.devontechnologies.com/u/cgrunenberg)
#### Post date: [January 27, 2022, 10:59am UTC](https://discourse.devontechnologies.com/t/smart-rule-to-add-date-to-filename-doesnt-always-work/69225/15 "2022-01-27T10:59:28Z")

</div>

> [@Blanc](#):
>
> could regional/language settings in macOS influence whether DT recognises the “day\_verbose, month\_verbose day\_numeric, year\_numeric” pattern?

In most cases (like this one) this doesn’t matter.

---

<div class="post-metadata">

### Author: ![amalis](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/amalis/32/10548_2.png) [@amalis](https://discourse.devontechnologies.com/u/amalis)
#### Post date: [January 27, 2022, 2:01pm UTC](https://discourse.devontechnologies.com/t/smart-rule-to-add-date-to-filename-doesnt-always-work/69225/16 "2022-01-27T14:01:34Z")

</div>

@cgrunenberg Sent, in your inbox.

Thanks!

---

<div class="post-metadata">

### Author: ![amalis](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/amalis/32/10548_2.png) [@amalis](https://discourse.devontechnologies.com/u/amalis)
#### Post date: [January 27, 2022, 2:03pm UTC](https://discourse.devontechnologies.com/t/smart-rule-to-add-date-to-filename-doesnt-always-work/69225/17 "2022-01-27T14:03:22Z")

</div>

@Blanc Copy and paste work fine. My regional and language settings are for US English, and US date and time styles.

---

<div class="post-metadata">

### Author: ![cgrunenberg](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/cgrunenberg/32/7172_2.png) [@cgrunenberg](https://discourse.devontechnologies.com/u/cgrunenberg)
#### Post date: [January 27, 2022, 2:19pm UTC](https://discourse.devontechnologies.com/t/smart-rule-to-add-date-to-filename-doesnt-always-work/69225/18 "2022-01-27T14:19:14Z")

</div>

Thanks for the sample! It’s unfortunately an issue of the PDF, the date is on separate lines in the text layer and that’s not recognized. Not sure if it’s caused by Gmail or MailPlane, maybe PDFs generated e.g. by Safari will work as expected.

---

<div class="post-metadata">

### Author: ![Blanc](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/blanc/32/8008_2.png) [@Blanc](https://discourse.devontechnologies.com/u/Blanc)
#### Post date: [January 27, 2022, 3:02pm UTC](https://discourse.devontechnologies.com/t/smart-rule-to-add-date-to-filename-doesnt-always-work/69225/19 "2022-01-27T15:02:38Z")

</div>

> [@cgrunenberg](#):
>
> It’s unfortunately an issue of the PDF

That’s what I assumed; why did copy&paste work without ado then? I had assumed - wrongly? - that c&p would show that up by pasting a result which mirrored the plain text of the PDF, so in this case was spread across 2 lines.

---

<div class="post-metadata">

### Author: ![BLUEFROG](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/bluefrog/32/135_2.png) [@BLUEFROG](https://discourse.devontechnologies.com/u/BLUEFROG)
#### Post date: [January 27, 2022, 3:49pm UTC](https://discourse.devontechnologies.com/t/smart-rule-to-add-date-to-filename-doesnt-always-work/69225/20 "2022-01-27T15:49:44Z")

</div>

Just to confirm: I **didn’t** have an issue with a PDF printed from Gmail’s web UI in Safari.

[Next page](https://discourse.devontechnologies.com/t/smart-rule-to-add-date-to-filename-doesnt-always-work/69225.md?page=2)
