Hey PowerShell Guy!, How Can I Delete Files That Are a Specified Number of Hours Old?
And another translation of a Hey Scripting Guy Article : How Can I Delete Files That Are a Specified Number of Hours Old?
dir |? {$_.CreationTime -lt (get-date).AddHours(-8)} | del -whatif
or for files not written in the last 8 hours :
dir |? {$_.LastWriteTime -lt (get-date).AddHours(-8)} | del -whatif
And yes the PowerShell version is with seatbelt included ( Remove -whatIf to really delete the files. )
Need I say more ?
enjoy,
Greetings /\/\o\/\/