Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

VBScript File Directory operations

$
0
0

I have the following codes that will delete files that are 2 days old; keeping 2 days worth of files on the directory.

For Each objFile in objFiles 
   If objFile.DateLastModified < (Date() - 2) Then
      objFile.Delete (True)
   End If
Next

The problem with that is, it's calculating weekends. No files will be created on weekends. So, on Monday, when the script runs, it'll delete everything older than Sunday; leaving only Monday's data. I would like to keep previous Friday and Monday - only deleting everything older than previous Friday.

I'm not sure how (or if possible) to incorporate the built-in function Weekday to my script.


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>