Skip to content

Commit

Permalink
Added date extractor from filename. 📈
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbeutler committed Mar 1, 2024
1 parent 94529a3 commit 5e6ed88
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@iperka/scan-categorizer",
"description": "Categorize your scanned documents and organize them in folders.",
"version": "2.0.2",
"version": "2.0.3",
"main": "index.js",
"license": "MIT",
"author": {
Expand Down
17 changes: 16 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,22 @@ namespace ScanCategorizer {
category: Query.Category,
onlyShortcut?: boolean,
) => {
const date: Date = new Date(file.getDateCreated().getTime());
let date: Date = new Date(file.getDateCreated().getTime());
if (
file.getName().match(/[1-2][0-9][0-9][0-9]-[0-1][0-9]-[0-3][0-9]/g)
.length === 1
) {
const d = file
.getName()
.match(/[1-2][0-9][0-9][0-9]-[0-1][0-9]-[0-3][0-9]/g)[0];
const dateArray = d.split('-');
(date = new Date(
parseInt(dateArray[0]),
parseInt(dateArray[1]) - 1,
parseInt(dateArray[2]),
)),
Logger.log('Date found in file name: ' + date);
}

// Check if custom name is defined.
const name =
Expand Down

0 comments on commit 5e6ed88

Please sign in to comment.