It is currently March 28th, 2024, 9:11 am

Timestamp on refresh

Get help with creating, editing & fixing problems with skins
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Timestamp on refresh

Post by jsmorley »

If you get around to it, it can be done with PowerShell like this:

Skin:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]
ImageName=#CURRENTPATH#TestMeta.jpg

[MeasureRun]
Measure=Plugin
Plugin=RunCommand
Program=PowerShell.exe
Parameter=-NoProfile -ExecutionPolicy Bypass -Command "& '.\ImageDate.ps1' '#ImageName#'"
OutputType=ANSI
FinishAction=[!ToggleMeter MeterSize][!UpdateMeter MeterSize][!Redraw]
RegExpSubstitute=1
Substitute="(?U).*([\d]{1,2})[\D]*([\d]{1,2})[\D]*([\d]{4})[\D]*([\d]{2}):([\d]{2})":"\3 \1 \2 \4:\5"

;Example result
;?9/?21/?2015 ??12:52 PM

[MeterImage]
Meter=Image
ImageName=#ImageName#
H=300
PreserveAspectRatio=1
LeftMouseUpAction=[!CommandMeasure MeasureRun "Run"]

[MeterSize]
Meter=String
MeasureName=MeasureRun
Y=5R
W=([&MeterImage:W]-10)
X=([&MeterImage:W] / 2)
StringAlign=Center
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
UpdateDivider=-1
Hidden=1
DynamicVariables=1
ImageDate.ps1:

Code: Select all

$file = Get-Item $args[0]

$shellObject = New-Object -ComObject Shell.Application
$directoryObject = $shellObject.NameSpace( $file.Directory.FullName )
$fileObject = $directoryObject.ParseName( $file.Name )

$property = 'Date taken'
for(
  $index = 5;
  $directoryObject.GetDetailsOf( $directoryObject.Items, $index ) -ne $property;
  ++$index ) { }

$value = $directoryObject.GetDetailsOf( $fileObject, $index )
write-host  $value
1.png
This is slightly different than using exiftool.exe, which directly reads the metadata of the image file, but rather reads the "Properties" elements returned by Windows in file explorer. Should work equally well.
Post Reply