![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | powershell script help - recursive delete based on modified date Hello all, I am a newbie when it comes to powershell. I need some assistance in writing a script that will perform a recursive delete on a folder on all files that match a certain extension (*.log) and are older than 3 months old. Any help would be much appreciated! TIA! |
My System Specs![]() |
| | #2 (permalink) |
| | Re: powershell script help - recursive delete based on modified date On Nov 12, 9:43*am, <par...@xxxxxx> wrote: Quote: > Hello all, > > I am a newbie when it comes to powershell. I need some assistance in writing > a script that will perform a recursive delete on a folder on all files that > match a certain extension (*.log) and are older than 3 months old. > > Any help would be much appreciated! > > TIA! $cutoff = (get-date).AddMonths(-3) Get-ChildItem -incl '*.log' -rec| ?{$_.LastWriteTime -lt $cutoff -and !$_.PSIsContainer}| remove-item -whatif Naturally you want to remove the -whatif to have the files actually removed:-) |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Sample script to delete lines from a file based on a string | PowerShell | |||
| Re: PS Script to automate checking date of file and delete if old | PowerShell | |||
| Modified Date used as Date Taken in Photo Gallery and Digital Imag | Vista music pictures video | |||
| Delete files based on last accessed date? | PowerShell | |||
| Delete based on date | PowerShell | |||