Dim fso, startFolder, OlderThanDate Set fso = CreateObject("Scripting.FileSystemObject") startFolder = "\\sadvnfs01\Scan-DVN\" ' folder to start deleting (subfolders will also be cleaned) OlderThanDate = DateAdd("d", -7, Date) ' 7 days (adjust as necessary) DeleteOldFiles startFolder, OlderThanDate Function DeleteOldFiles(folderName, BeforeDate) Dim folder, file, fileCollection, folderCollection, subFolder Set folder = fso.GetFolder(folderName) Set fileCollection = folder.Files For Each file In fileCollection If file.DateLastModified < BeforeDate Then fso.DeleteFile(file.Path) End If Next Set folderCollection = folder.SubFolders For Each subFolder In folderCollection DeleteOldFiles subFolder.Path, BeforeDate Next End Function
|How can i reset all images size to default in a word file||6||58|
|Vb script to unzip a files and rename the files||12||95|
|VB Script/Bat: check if a file has been modified based on prefix||10||59|
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
19 Experts available now in Live!