{"id":2473,"date":"2013-04-05T15:21:41","date_gmt":"2013-04-05T19:21:41","guid":{"rendered":"http:\/\/www.iowawebnet.com\/ein\/?p=2473"},"modified":"2013-05-09T10:41:41","modified_gmt":"2013-05-09T14:41:41","slug":"delete-old-images-vb-script","status":"publish","type":"post","link":"https:\/\/www.iowawebnet.com\/ein\/2013\/04\/delete-old-images-vb-script\/","title":{"rendered":"Delete old images &#8211; VB Script"},"content":{"rendered":"<pre>\r\nCopy this code into notepad and save as DeleteOldImages.vbs\r\n\r\n<code>\r\n'******************* Start of Code *************************\r\n\r\nOption Explicit \r\nOn Error Resume Next \r\nDim oFSO, oFolder, sDirectoryPath  \r\nDim oFileCollection, oFile, sDir  \r\nDim iDaysOld \r\n\r\n' Specify Directory Path From Where You want to clear the old files \r\n\r\nsDirectoryPath = \"C:\\Users\\mike\\Desktop\\Test\" \r\n\r\n' Specify Number of Days Old File to Delete\r\n\r\niDaysOld = 15\r\n\r\nSet oFSO = CreateObject(\"Scripting.FileSystemObject\") \r\nSet oFolder = oFSO.GetFolder(sDirectoryPath) \r\nSet oFileCollection = oFolder.Files \r\n\r\nFor each oFile in oFileCollection\r\n\r\n'This section will filter the text file as i have used for for test \r\n'Specify the Extension of file that you want to delete \r\n'and the number with Number of character in the file extension  \r\n\t\r\n  If LCase(Right(Cstr(oFile.Name), 3)) = \"png\" \r\n     OR LCase(Right(Cstr(oFile.Name), 3)) = \"gif\"  \r\n     OR LCase(Right(Cstr(oFile.Name), 3)) = \"jpg\" Then\r\n \t\r\n \tIf oFile.DateLastModified < (Date() - iDaysOld) Then \r\n           oFile.Delete(True) \r\n        End If \r\n\r\n\tEnd If     \r\nNext \r\n\r\nSet oFSO = Nothing \r\nSet oFolder = Nothing \r\nSet oFileCollection = Nothing \r\nSet oFile = Nothing \r\n\r\n'************************ End of Code ********************\r\n<\/code>\r\n\r\nCredit for this script - \"Sidd\"\r\nhttp:\/\/www.symantec.com\/connect\/downloads\/vbscript-delete-old-files\r\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Copy this code into notepad and save as DeleteOldImages.vbs &#8216;******************* Start of Code ************************* Option Explicit On Error Resume Next Dim oFSO, oFolder, sDirectoryPath Dim oFileCollection, oFile, sDir Dim iDaysOld &#8216; Specify Directory Path From Where You want to clear the old files sDirectoryPath = &#8220;C:\\Users\\mike\\Desktop\\Test&#8221; &#8216; Specify Number of Days Old File to Delete [&hellip;]<\/p>\n","protected":false},"author":35,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[85,17,16],"tags":[134,135,137,136],"class_list":["post-2473","post","type-post","status-publish","format-standard","hentry","category-net-4-0","category-applications","category-net","tag-delete","tag-files","tag-vbs","tag-vbscript"],"_links":{"self":[{"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/posts\/2473"}],"collection":[{"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/comments?post=2473"}],"version-history":[{"count":4,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/posts\/2473\/revisions"}],"predecessor-version":[{"id":2478,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/posts\/2473\/revisions\/2478"}],"wp:attachment":[{"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/media?parent=2473"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/categories?post=2473"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/tags?post=2473"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}