Deleting files based on modified date in PowerShell
Hey scripting guy! I am a complete n00b to scripting in PowerShell (kid gloves please), however, it has become a great interest of mine to learn and I think I have the perfect starting point. I need to run a script on a regular basis that searches a collection of folders all under a single parent folder for files with a modified date older than 2 weeks, and then deletes them. What I DON'T want the script to do is delete any folders - just files (all files). So here's the scenario: My parent folder that contains dozens, if not hundreds, of subfolders is "\\ftp" and I can map a drive if need be. Again, no special requests, just needs to delete all files anywhere under the parent folder older than 2 weeks but no folders, just files. Thanks for any help you can give and if I was not descriptive enough I apologize, just let me know.
March 9th, 2010 1:03am

Hello, Here is a PowerShell script to delete files(logs) older than however many days you define:http://myitforum.com/cs2/blogs/yli628/archive/2007/10/02/powershell-script-to-delete-files-older-than-certain-days.aspx I recommend you move this thread to Scripting Guys Forum. It is more appropriate for scripting questions. Thomas77
Free Windows Admin Tool Kit Click here and download it now
March 9th, 2010 11:18am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics