Automatic deletion of files by date
Page 1 of 1

Author:  KaiBo [ Tue Mar 31, 2009 8:10 pm ]
Post subject:  Automatic deletion of files by date

Just clicked this little PowerShell-Script together to get rid of some files which are being constantly being created but won't be used anymore if they get too old. Thought that some of you might have a use or two for it as well (think of logs):
Get-ChildItem -incl '*.mp4' -path 'd:\shares\users\axis\*'|
?{$_.LastWriteTime -lt (get-date).AddDays(-7) -and !$_.PSIsContainer}|

What it basically does: Delete every .mp4-File from c:\shares\users\axis which is older than seven days. Feel free to adapt it as necessary.

If you put " -whatif" at the end of it all it will just show you which files are selected by the above statement instead of deleting them.

Page 1 of 1 All times are UTC - 7 hours [ DST ]
Powered by phpBB® Forum Software © phpBB Group