I need to delete files older than two days inside a folder, except files last modified the 1st of each month. Forfiles does not support exceptions. Operating System is Windows Server 2003. Any idea?
Thank you all for help!
scriptingwindows-server-2003
I need to delete files older than two days inside a folder, except files last modified the 1st of each month. Forfiles does not support exceptions. Operating System is Windows Server 2003. Any idea?
Thank you all for help!
Best Answer
Quick and dirty VBScript here, it assumes UK date format for enumerating if the file is from the 1st of the month. If you use a different date format then change the trim command to grab the appropriate number positions. For example, a US date would be Mid(objFile.DateLastModified, 4, 2) = 01 rather than Left(objFile.DateLastModified, 2) = 01
Anyway, sorry for the dirty code... but it should get you started.