It is currently December 5th, 2021, 4:23 pm

Small skin to monitor age of latest file in folder

General topics related to Rainmeter.
Ruff_hi
Posts: 19
Joined: August 21st, 2018, 1:30 pm

Small skin to monitor age of latest file in folder

Post by Ruff_hi »

I run nightly backups using Acronis to two locations. The O drive (OneDrive) that gets replicated to the cloud and the Y drive that is my local NAS server. It is set up to email me, but I get lots of overnight emails containing various status information.

Anyway, my backups had stopped working about a month ago, and I had failed to notice.

I started with code from here (https://pastebin.com/dyAzAM2J) and cut it down to just list the latest file in each location. I can then glance at the date / time of the file to see if it has been updated as part of the overnight runs.

I now want to go a step further and change the date / time to red if it is older than 24 hours.

I have the date / time of the latest modified file ...

Code: Select all

[measureFile1Date]
Measure=Plugin
Plugin=FileView
Path=[measurePath1]
Type=FileDate
Index=2
I can get today's date ...

Code: Select all

[MeasureNow]
Measure=Time
Format=%#m/%#d/%Y
Here is my calculation ...

Code: Select all

[measureFile1InfoAge]
measure=CALC
formula=(measureFile1Date - [MeasureNow]) / 86400
I can display the 'measureFile1Date / 86400' (answer 153621) but it returns zero if I display '[MeasureNow] / 86400'

Can I compare these two dates?

Edit: The attachment is the latest version of my skin.
You do not have the required permissions to view the files attached to this post.
Last edited by Ruff_hi on August 9th, 2021, 11:40 am, edited 2 times in total.
User avatar
SilverAzide
Rainmeter Sage
Posts: 1670
Joined: March 23rd, 2015, 5:26 pm

Re: Small skin to monitor age of latest file in folder

Post by SilverAzide »

Have you tried:

Code: Select all

Formula=(measureFile1Date - [MeasureNow:Timestamp]) / 86400
(just guessing... :confused:, and if that doesn't work, add DynamicVariables=1, I can never remember when that is needed.)
Gadgets Wiki GitHub More Gadgets...
User avatar
Yincognito
Rainmeter Sage
Posts: 4108
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Small skin to monitor age of latest file in folder

Post by Yincognito »

SilverAzide is right, you need to use the timestamp of [MeasureNow], though I believe that in order to get the "age" of a file you'd need to reverse the operands in your formula, like:

Code: Select all

Formula=(([MeasureNow:Timestamp]-measureFile1Date)/86400)
There shouldn't be a need for DynamicVariables=1 added to the measure since it can be skipped for measure values in Calc measures, but it can't hurt to add it.
Ruff_hi
Posts: 19
Joined: August 21st, 2018, 1:30 pm

Re: Small skin to monitor age of latest file in folder

Post by Ruff_hi »

Thx guys ... that worked. Still have to work out how to change the color to RED if age is > 1 ... but I am sure I can google a few answers to that.
User avatar
Yincognito
Rainmeter Sage
Posts: 4108
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Small skin to monitor age of latest file in folder

Post by Yincognito »

Ruff_hi wrote: August 8th, 2021, 6:14 pmStill have to work out how to change the color to RED if age is > 1 ... but I am sure I can google a few answers to that.
Add something along these lines to your [measureFile1InfoAge] measure:

Code: Select all

IfCondition=(measureFile1InfoAge>1)
IfTrueAction=[!SetOption SomeRelatedMeter FontColor "255,0,0,255"][!UpdateMeter SomeRelatedMeter][!Redraw]
IfFalseAction=[!SetOption SomeRelatedMeter FontColor "255,255,255,255"][!UpdateMeter SomeRelatedMeter][!Redraw]
IfConditionMode=1
DynamicVariables=1
although, depending on how you have it in your skin this would probably suffice:

Code: Select all

IfCondition=(measureFile1InfoAge>1)
IfTrueAction=[!SetOption SomeRelatedMeter FontColor "255,0,0,255"]
The SomeRelatedMeter is the meter where you display the said date / time value.
Ruff_hi
Posts: 19
Joined: August 21st, 2018, 1:30 pm

Re: Small skin to monitor age of latest file in folder

Post by Ruff_hi »

Thx All. I have it working now.

Attached is my ini file.
Edit: Removed as it was stale.
Last edited by Ruff_hi on August 9th, 2021, 11:39 am, edited 2 times in total.
User avatar
jsmorley
Developer
Posts: 22416
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Small skin to monitor age of latest file in folder

Post by jsmorley »

Not to butt in, well actually to butt in, I have the exact same requirement for a nightly full-system, single instance backup with Acronis on my system. I like see at at glance that it worked the night before when I get up. I did this:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
MouseScrollDownAction=[!Refresh #CURRENTCONFIG#]

[Variables]
@Include1=#@#GeneralVariables.inc

[MeasureUpdate]
Measure=Calc
Formula=1
OnUpdateAction=[!CommandMeasure MeasureFolder "Update"]
UpdateDivider=3600

[MeasureFolder]
Measure=Plugin
Plugin=FileView
Path=E:\
ShowDotDot=0
ShowFolder=0
WildcardSearch=Nightly-*.tibx
SortType=Size
Count=5

[MeasureCount]
Measure=Plugin
Plugin=FileView
Path=[MeasureFolder]
Type=FileCount
IfCondition=MeasureCount <> 1
IfTrueAction=[!SetOption MeterFileLabel Text "[[MeasureCount]] Files!"][!SetOption MeterFileLabel FontColor "255,65,51,255"][!UpdateMeter *][!Redraw]
IfFalseAction=[!SetOption MeterFileLabel Text "[[MeasureCount]] Backup:"][!SetOption MeterFileLabel FontColor ""][!UpdateMeter *][!Redraw]

[MeasureFile]
Measure=Plugin
Plugin=FileView
Path=[MeasureFolder]
Type=FilePath

[MeasureSize]
Measure=Plugin
Plugin=FileView
Path=[MeasureFolder]
Type=FileSize

[MeasureDate]
Measure=Plugin
Plugin=FileView
Path=[MeasureFolder]
Type=FileDate

[MeterAllBackground]
Meter=Shape
Shape=Rectangle 0.5,0.5,300,75,12 | Fill Color #BackgroundColor# | StrokeWidth 1.5 | Stroke Color #FrameColor#
UpdateDivider=-1
LeftMouseUpAction=["E:\"]

[StyleGeneral]
X=15
FontFace=#TextFont#
FontSize=11
FontWeight=400
FontColor=#LabelColor#
NumOfDecimals=0
AntiAlias=1

[StyleValue]
X=290
Y=0r
FontColor=#ValueColor#
StringAlign=Right

[MeterFileLabel]
Meter=String
MeterStyle=StyleGeneral
Y=10
Text=File Name:

[MeterFileName]
Meter=String
MeterStyle=StyleGeneral | StyleValue
MeasureName=MeasureFile

[MeterDateLable]
Meter=String
MeterStyle=StyleGeneral
Y=3R
Text=File Date:

[MeterFileDate]
Meter=String
MeterStyle=StyleGeneral | StyleValue
MeasureName=MeasureDate

[MeterSizeLable]
Meter=String
MeterStyle=StyleGeneral
Y=3R
Text=File Size:

[MeterFileSize]
Meter=String
MeterStyle=StyleGeneral | StyleValue
MeasureName=MeasureSize
NumOfDecimals=2
AutoScale=1
Text=%1B

1.jpg


So if it says [2] or [0] backups, and is all red and angry, I know I'm in trouble.
You do not have the required permissions to view the files attached to this post.
User avatar
Yincognito
Rainmeter Sage
Posts: 4108
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Small skin to monitor age of latest file in folder

Post by Yincognito »

jsmorley wrote: August 8th, 2021, 9:01 pmNot to butt in, well actually to butt in [...]
Oh, but feel free to butt in - no problem, it's not like we're exclusive here. :thumbup: Especially since the cases are pretty much identical. Don't know if the backup type (full, incremental, etc.) would have a relevance here, but other than that, your nice little skin fits the scenario like a glove. ;-)
User avatar
jsmorley
Developer
Posts: 22416
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Small skin to monitor age of latest file in folder

Post by jsmorley »

Yincognito wrote: August 8th, 2021, 9:16 pm Oh, but feel free to butt in - no problem, it's not like we're exclusive here. :thumbup: Especially since the cases are pretty much identical. Don't know if the backup type (full, incremental, etc.) would have a relevance here, but other than that, your nice little skin fits the scenario like a glove. ;-)
Yeah, take a little thought to properly support incremental backups, but the basic concept should work.

I have done a full backup of my system since there were PC's with hard drives, starting with FastBack and a boatload of floppies in the early days (not so bad with a 10mb hard drive) to automatically every night with Acronis for probably the last 15 years or so. I have never "lost" a byte of data.
User avatar
Yincognito
Rainmeter Sage
Posts: 4108
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Small skin to monitor age of latest file in folder

Post by Yincognito »

jsmorley wrote: August 8th, 2021, 9:23 pmI have done a full backup of my system since there were PC's with hard drives, starting with FastBack and a boatload of floppies in the early days (not so bad with a 10mb hard drive) to automatically every night with Acronis for probably the last 15 years or so. I have never "lost" a byte of data.
Yep, me too: evolved from floppies like yourself, to CD/DVDs, to Ghost, to Acronis, to RollBack RX (technically, not a backup, but extremely quick and efficient IF you were careful and knew what you were doing), to RollBack RX + Acronis (as a plan A + plan B), to Macrium Reflect (not actually used, but just in case), to external HDDs. I currently find it easier to just copy data to my external drives, as with the rate at which sofware and system drive is changing nowadays making a system backup gets obsolete really quickly.