October 9, 2008 at 11:49 am
Here's a powershell script that might be of use (I'm a novice at Powershell, but this is what it's good at...)
$a=get-date
$t=new-timespan -hours 1
$a=$a-$t
get-childitem -path t:\|where-object -filterScript{$_.LastWriteTime -le $a}|Remove-item
Basically, we load the current date/time into $a, then we create a difference value ($t) of 1 hour (this could be any timespan - you can set it down to the millisecond). So if $a is 10-9-2008 2:00 pm, after $a=$a-$t, $a will be 10-9-2008 1:00 pm. The last statement selects all files (get-childitem) from the designated path (t:\) - you can use wildcard (t:\*.txt) or regular expressions in the path parameter - the list of files is passed to the where-object, which filters out anything newer than $a - actually selects all files with LastWriteTime more than 1 hour ago. The filtered list is passed to Remove-item, which deletes all the files.
-Eric
[font="Tahoma"]Eric Flamm, Flamm Consulting[/font]
Viewing post 16 (of 16 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy