
March 23rd, 2007, 03:42 PM
|
|
Registered User
|
|
Join Date: Mar 2007
Posts: 2
Time spent in forums: 29 m 43 sec
Reputation Power: 0
|
|
|
Automatic File update
I'm looking for something like JamesLe's VB script that Shadow wizard modified...
Quote: | Originally Posted by Shadow Wizard here is the modified script:
VB Code:
Original
- VB Code |
|
|
|
Option Explicit Dim fso Set fso = CreateObject("Scripting.FileSystemObject") Call DeleteFiles(fso.GetFolder("C:\Test"), 7, ".txt") '<----- Change this folder name to match with your case. Sub DeleteFiles(srcFolder, daysCount, strExtension) Dim srcFile, filesCount filesCount = 0 If srcFolder.Files.Count = 0 Then Wscript.Echo "No File to Delete" Exit Sub End If For Each srcFile in srcFolder.Files If DateDiff("d", Now, srcFile.DateCreated) < ((-1)*daysCount) Then If (strExtension="") Or (Right(UCase(srcFile.Name), Len(strExtension))=UCase(strExtension)) Then fso.DeleteFile srcFile, True filesCount = filesCount+1 End If End If Next Wscript.Echo filesCount & " Files Deleted successfully" End Sub
|
I really like the idea and could find much use for such a script. As opposed to outright deleting the file, I would like to overwrite it with a copy of a more current file from another location (i.e. from a network drive).
Any VB experts willing to help me tweak it some more? Thanks in advance!
|