keep files from first of the month for a year
we have series of folders subfolders have logfiles in them. each folder has new log files generated daily. on occasion, log file not generated day or few days.
i want keep log file in each folder first of each month, or close day possible year , delete files older year. want delete files in folder not first of month.
so, on august 30, 2014 folder 1 may have log files each day in august except august 1. when run script on september 1, want folder have files:
august 02, 2014.log
july 01, 2014.log
june 01, 2014.log
if first log file august 5th, want keep 1 , delete rest.
i have 30+ folders daily log files. takes long time go each folder, see log closest beginning of month, delete remaining files month, find log files on year ago , delete one.
ive tried few iterations but, keep getting stuck. appreciated.
thanks!
steve
im not sure how convert $testdate date , not time.can use $testdate.date date portion only:
ps c:\scripts\powershell scripts\misc testing\9-3-2014> $testdate.date saturday, may 31, 2014 12:00:00 am
don't retire technet! - (don't give yet - 13,085+ strong , growing)
Windows Server > Windows PowerShell
Comments
Post a Comment