RegEx column - good for this task?

Hi,

I'm using https://resource.dopus.com/t/column-custom-text-and-regexp/18727 to add a date column. Works fine of course. Thanks for this script! The new column should express the date where a certain product warranty expires.

I've got many filenames reading like those examples: "2020-06-06 Amazon SSD (2 years warranty).pdf" or as second example "2020-01-02 Amazon WD harddisk (3 years warranty).pdf".

So, basically each filename contains a date where a product was delivered and a number of years the warranty of this product will expire in the future.

Now, the new RegeEx column should calculate tha new date, for the first example: 2022-06-06 and for the second example 2023-01-02. Its simple math of course but maybe the RegEx column could extract the leading date, add a given amount of years and put this new date into the new column.

Simple, isn't it? Of course, it maybe an easy task using some VB scripting or similar, but is it possible for a regular expression, too? Is the RegEx column script the right tool?

Michael

Regular Expressions can only find and replace text. They can't do arithmetic. You'd need to use script code for that part (maybe using a regex to extract the date first).

You could modify the script to do this, but it would be very specific to your use case.

I think a generic solution that that others might benefit from would be quite complex. We would need to create a simple language, so people could say, column[exp]=column[year]+column[warranty].

An alternate solution would be to add the expiry date to the file name. It will be a pain to go through and do it, but would be quite achievable and would give you your desired outcome of the exp column "2020-01-02 Amazon WD harddisk (3 years warranty[Exp:2023-01-02]).pdf ". You could script the update to the files names. Its not what you wanted though.

So I've created a JS and added a custom column of type date that contains the calculated date now :laughing:

Next step I tried is to create a label assignment that should colorize an item in the lister if the current date is equal or greater than the date in this new column.

Goal is to get all files labeled that are already "overdue". I noticed, or maybe I'm not very firm in creating assignments, that this might not be an easy task or maybe not possible at all - I'm I correct?

One possible solution that just came into my mind is to create a second column that contains a flag/a content only if the day is reached. I could then use this flag column in a label assignment. Would that be possible, too, if I do not display this helper column in the lister?

Michael