Quantcast
Channel: Unable to extract date from file name
Viewing all articles
Browse latest Browse all 11

Unable to extract date from file name

$
0
0

As the script stands now, it relies on the custom metadata field “DateDuFichier”. That is by no means necessary, the script could simply extract the date information from the file name and set the creation date accordingly.

Not complicated, just more code:

function performsmartrule(records) {
  const app = Application("DEVONthink 3");
  records.forEach(r => {
     const match = r.name().match(/(.*?)\s+-\s+(\d{4})(\d\d)(\d\d)\s+-\s+(.*)/);
     if (match) {
        const company = match[1];
        const objet = match[5];
        const date = new Date(`match[2]-match[3]-match4`);
        r.creationDate = date;
        app.addCustomMetaData(company, {for: 'company', to: r});
        app.addCustomMetaData(objet, {for: 'objet', to: r});
     }
  })
)

This code is not tested at all. It does not set the modification date (that would be an additional line), since I don’t see the point of having identical creation and modification dates. If needed, that’s left as an exercise to the reader.

This script can be the sole action in a smart rule (Execute Script/JavaScript). No need for “Scan Name” etc.

Read full topic


Viewing all articles
Browse latest Browse all 11

Latest Images

Trending Articles





Latest Images