How to extract data from FILE NAME name to CREATED DATE

Hello there,

I now used to create all documents in this manner:

YY— #Main-Tag – [description], [company resort]—YYYY-MM-DD

Which will look like
20— #Parking – NYC, ACME Corp—2020-04-12

As I often scan the documents on another day as when they are created now my question:
How can I extract the date set in the filename so that DEVONthink saves it as the Creaton date of the file?

@Blanc 's post here Smart Rule: OCR and rename on pdf import got me on the right track.

I created a smart rule with the following settings
OCR — Apply
Scan Text — Date – *
Change Name — [Year of newest date]— # - [Suggested Name]—[Newest date YYYY-MM-DD]
Change Creation Date — Newest date

Works like a charm!!!

2 Likes

The batch processing and smart rule actions don’t support such a case as the Scan Name > Date action requires a prefix and/or suffix. Therefore the only possibility is to script this.

Proved to find a workaround - see my solution above :)))))

But can you script this specific option?

Would be really greatful

Without implementing this functionality on your own the easiest solution is to…

  • set up such a smart rule which is executed only on demand
  • use the “perform smart rule” command in your script to apply this smart rule to one or more records

I’m not good at scripting - do you have a line for me for specificly reading out the filename / document name and set that as creation date?

There’s no such line, this would require a much more complex script (unless you want to implement the easier solution based on perform smart rule). However, just wondering what’s the purpose of your script approach when the smart rule already does the job?

I have already set many filenames by hand

I also tried to use Scan Name but that does not recognize any date in the filename :frowning:
I’ve set it up similar to the above way for test purpose:

Scan Name | Date | *
Show Warning | *
Show Warning | Newest Date

It always shows an empty message.

I tried:
20— #Food 2,39€ Coffee—2020-03-01
20— #Food 2,39€ Coffee— 2020-03-01
2020-03-01
01.03.2020 (german date format)

And what about the above workaround? I assumed that you use this now.

Not sure if you still need this but if you want to change creation dates you might find this a good starting point Change creation date based on file name

1 Like

Yes that might work :)) Thanks!

Yes for new documents, but I need a way for the old ones (about 800).
I will try the script @pete31 suggested