Biz IT?ciler için çoğu zaman başımıza gelen bir durum. Devamlı olarak takip ettiğimiz bir folder’da son 3 gün içerisinde oluşturulan dosyaların haricindekileri silmek istediğimizde aşağıdaki script imdadımıza yetişecektir…Yaparsınız bir Schedule, bakarsınız keyfinize…
Örneğin son 7 gün haricindeki diğer dosyaların saklanmasını istemiyorsak aşağıdaki script?i bir notepad?e kopyaladıktan sonra ?delold.vbs? olarak kayıt ediyoruz. Sonrası size kalmış.
Dosya kullanımı için değiştirmeniz gereken satırlar aşağıda işaretlediğim alanlar:
Path= ?Silmek istediğimiz dizini yazıyoruz?
LifeTime=date()-20 ?> Son 20 günlük dosyanın haricindekilerin silinmesi için kullanıyoruz.
Sonrasında çalıştırmaya geliyor sıra.
Bunun için Start- Run – cscript C:\delold.vbs
‘ delold.vbs ‘ *************************************************** ‘ * This script will delete all files in a folder and ‘ * sub-folder where when files are x number of days ‘ * old. ‘ * ‘ * Files will be deleted and not retained in the ‘ * recycle bin. ‘ * ‘ * Alter the path and lifetime variables to your needs ‘ * Alter this variable, this is the starting point Path = “D:\DATA” ‘ * Alter this variable, if sub-folders should be processed Subfolders = False ‘ * Example : lifetime = date() – 20 Lifetime = date() – 1 ‘ ******************************************************* FilesArray = Array() ‘ Create an instance of the FileSystemObject so that file set fso = createobject(“scripting.filesystemobject”) ‘ Call the SelectFiles procedure to Fill the array with SelectFiles path, lifetime, FilesArray, Subfolders ‘ Process the FilesArray deleting files as we loop through numDeleted = 0 for n = 0 to ubound(FilesArray) sub SelectFiles(sPath,vlifetime,FilesArrayToKill,bIncludeSubFolders) ‘ Loop through files that have been found dtlastmodified = null if not isnull(dtlastmodified) Then ‘ If sub-folders are selected, call the procedure again to update if bIncludeSubFolders then |