﻿{"id":314,"date":"2012-10-14T16:16:58","date_gmt":"2012-10-14T19:16:58","guid":{"rendered":"http:\/\/binsfeld.com.br\/wp\/?p=314"},"modified":"2012-10-14T16:18:31","modified_gmt":"2012-10-14T19:18:31","slug":"vbs-apagar-arquivos-antigos-e-mover-para-pasta","status":"publish","type":"post","link":"http:\/\/binsfeld.com.br\/wp\/?p=314","title":{"rendered":"VBS Apagar Arquivos Antigos e Mover para Pasta"},"content":{"rendered":"<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/p>\n<p>Set FSo = CreateObject(&#8220;Scripting.FileSystemObject&#8221;)<br \/>\nSet folder = FSO.getFolder (&#8220;M:\\millsys\\millgest\\magnet\\comercial&#8221;)<br \/>\nfor each file in folder.files<br \/>\nif (dateDiff(&#8220;d&#8221;, file.DateLastModified, now) &gt;60) then<br \/>\nFile.delete<br \/>\nend if<br \/>\nnext<\/p>\n<p>Dim SOURCE, TARGET<br \/>\nDim fso, SourceObj<\/p>\n<p>SOURCE = &#8220;M:\\millsys\\millgest\\magnet\\comercial&#8221;<br \/>\nTARGET = &#8220;D:\\Publico\\MagnetComercial&#8221;<\/p>\n<p>Set fso = CreateObject(&#8220;Scripting.FileSystemObject&#8221;)<br \/>\nSet SourceObj = fso.GetFolder(SOURCE)<\/p>\n<p>RecrusiveSearch SourceObj<\/p>\n<p>Set SourceObj = Nothing<br \/>\nSet fso = Nothing<\/p>\n<p>Private Sub RecrusiveSearch(sFolder)<br \/>\nDim fld, fil<br \/>\nDim strMonth, strDay, strYear, strDate<\/p>\n<p>strMonth = &#8220;0&#8221; &amp; Month(Date)<br \/>\nstrMonth = Right(strMonth, 2)<br \/>\nstrDay = &#8220;0&#8221; &amp; Day(Date)<br \/>\nstrDay = Right(strDay, 2)<br \/>\nstrYear = Year(Date)<\/p>\n<p>strDate = strYear &amp; strMonth &amp; strDay &amp; &#8220;_&#8221;<\/p>\n<p>If DateDiff(&#8220;d&#8221;, sFolder.DateLastModified, Now) &gt; 10 Then<br \/>\nfso.CopyFolder sFolder.Path, Target &amp; &#8220;\\&#8221; &amp; strDate &amp; sFolder.Name<br \/>\nfso.DeleteFolder sFolder<br \/>\nExit Sub<br \/>\nEnd If<\/p>\n<p>For Each fld In sFolder.SubFolders<br \/>\nRecrusiveSearch fld<br \/>\nNext<\/p>\n<p>For Each fil In sFolder.Files<br \/>\nIf DateDiff(&#8220;d&#8221;, fil.DateLastModified, Now) &gt; 10 Then<br \/>\nfso.CopyFile fil.Path, Target &amp; &#8220;\\&#8221; &amp; strDate &amp; fil.Name<br \/>\nfso.DeleteFile fil<br \/>\nEnd If<br \/>\nNext<br \/>\nEnd Sub<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\nCr\u00e9ditos : http:\/\/www.vbforums.com\/showthread.php?578210-Recurse-through-sub-directories-Files-older-then-30-days<br \/>\nhttp:\/\/www.purainfo.com.br\/scripts\/vbsapagando-arquivos-antigos\/<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; Set FSo = CreateObject(&#8220;Scripting.FileSystemObject&#8221;) Set folder = FSO.getFolder (&#8220;M:\\millsys\\millgest\\magnet\\comercial&#8221;) for each file in folder.files if (dateDiff(&#8220;d&#8221;, file.DateLastModified, now) &gt;60) then File.delete end if next Dim SOURCE, TARGET Dim fso,<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-314","post","type-post","status-publish","format-standard","hentry","category-outros"],"_links":{"self":[{"href":"http:\/\/binsfeld.com.br\/wp\/index.php?rest_route=\/wp\/v2\/posts\/314"}],"collection":[{"href":"http:\/\/binsfeld.com.br\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/binsfeld.com.br\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/binsfeld.com.br\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/binsfeld.com.br\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=314"}],"version-history":[{"count":9,"href":"http:\/\/binsfeld.com.br\/wp\/index.php?rest_route=\/wp\/v2\/posts\/314\/revisions"}],"predecessor-version":[{"id":382,"href":"http:\/\/binsfeld.com.br\/wp\/index.php?rest_route=\/wp\/v2\/posts\/314\/revisions\/382"}],"wp:attachment":[{"href":"http:\/\/binsfeld.com.br\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=314"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/binsfeld.com.br\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=314"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/binsfeld.com.br\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=314"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}