I can't answer this in detail now (maybe tomorrow), but there are multiple problems with your code:
- FileView parent measures only take folders as the value of their Path option, not files
- because of the above, a FileView child measure getting the last modified date of the file corresponding to a certain Index would be needed
- even so, since the Index option is a positional and not a name value of a file or folder from Path, you'd need to use the WildcardSearch option to specify your file in the parent FileView measure
- the options you used to get the last modified date in the FileView measure are wrong, see the Rainmeter manual for the FileView plugin
- once you get that date, you need to pass it to a Time measure having the proper TimeStampFormat option, see the manual for the Time measure
- once you have the Time measure, you'll need to use [YourTimeMeasure:Timestamp] to be able to compare it with some other Time measure's :Timestamp
- IfConditions are only used in measures, not meters
- DynamicVariables=1 might be needed in certain sections from the code
The needed changes are not particularly complicated, but they involve a few more steps to get what you want. Oh, and for the record, Lua is not absolutely needed to read a file, a WebParser measure having its URL option set to a local file can do it too (just saying, I guess that part is the only one working in your code already).
MeasureFile is returning a string, and MeasureTime is returning a timestamp (a number). So your comparsion IfCondition=(MeasureFile < MeasureTime) can't work.
You can convert the MeasureTime string to a "real" time using another Time measure. Once you do that, you can compare the two resulting timestamps and it should work.
SeubZero wrote: ↑February 15th, 2024, 10:51 pm
Hello everyone and sorry for my English.
I'm looking to change the color of text based on the last modification date of a file.
For this I use Jeffrey Morley's module, LuaTextFile2.0
The module simply reads the contents of a TXT file.
I would like to change the text color based on the last modification date of a specific file.
I try to adapt the module but it doesn't work, maybe the problem is Meter Display
Thank you all for your help.
Sincerely,
You are close to the answer...
Let's start by creating a new variable 'SearchFile' and set it's value to 'test.txt'
; Reads the 'Path' and contains one file information, if 'SearchFile' is found
[MeasureFile]
Measure=Plugin
Plugin=FileView
Path="C:\Temp"
ShowDotDot=0
ShowFolder=0
Count=1
WildcardSearch=#SearchFile#
To tell if the parent measure found a file, add a FileView measure that shows the FileCount value of the parent measure
Next, we need to know the current time, compare it to MeasureFileDate, and change the fontcolor
If the file is not found, the NUMBER value of [MeasureFileDate] will be zero
Note: IfConditions will ALWAYS use the NUMBER value of the measures, so the Timestamp values are used to compare the dates
[MeterDisplay]
Meter=String
MeasureName=MeasureFileDate
W=300
H=500
FontFace=Segoe UI
FontSize=11
FontColor=255,255,255,255
SolidColor=0,0,0,1
AntiAlias=1
ClipString=1
Text=FILE: #SearchFile##CRLF#MODIFIED: %1
; Condition pour changer la couleur du texte si la date de modification est inférieure à la date d'aujourd'hui
; DynamicVariables=1
That corrects the measures in your code.
Let us know if you have any questions.
[Rainmeter]
Author=Jeffrey Morley
Update=1000
DynamicWindowSize=1
[Variables]
SearchFile=text.txt
; Reads the 'Path' and contains one file information, if 'SearchFile' is found
[MeasureFile]
Measure=Plugin
Plugin=FileView
Path="C:\Temp"
ShowDotDot=0
ShowFolder=0
Count=1
WildcardSearch=#SearchFile#
; Added only for information
; Show the number of files found in the parent measure, in the log
[MeasureFileCount]
Measure=Plugin
Plugin=FileView
Path=[MeasureFile]
Type=FileCount
[MeasureFileDate]
Measure=Plugin
Plugin=FileView
Path=[MeasureFile]
Index=1
Type=FileDate
DateType=Modified
[MeasureTime]
Measure=Time
IfCondition=(MeasureFileDate < MeasureTime)&&(MeasureFileDate <> 0)
IfTrueAction=[!SetOption MeterDisplay FontColor "255,0,0,255"][!UpdateMeter MeterDisplay][!Redraw]
[MeterDisplay]
Meter=String
MeasureName=MeasureFileDate
W=300
H=500
FontFace=Segoe UI
FontSize=11
FontColor=255,255,255,255
SolidColor=0,0,0,1
AntiAlias=1
ClipString=1
Text=FILE: #SearchFile##CRLF#MODIFIED: %1
; Condition pour changer la couleur du texte si la date de modification est inférieure à la date d'aujourd'hui
; DynamicVariables=1
NOTE:
With the current IfCondition test in [MeasureTime] every file will be older than the current time. To test for older modified dates, all you need to do is to subtract the number of daily seconds (86400) from the MeasureTime in the IfCondition test.
E.g. To test for files modified more than 3 days ago use this IfCondition: IfCondition=(MeasureFileDate < (MeasureTime - (86400 * 3)))&&(MeasureFileDate <> 0)
You do not have the required permissions to view the files attached to this post.