{"id":1368,"date":"2014-07-31T04:22:59","date_gmt":"2014-07-31T09:22:59","guid":{"rendered":"http:\/\/wildow.com\/?p=1368"},"modified":"2014-07-31T04:59:25","modified_gmt":"2014-07-31T09:59:25","slug":"using-robocopy-to-delete-old-files-from-folder","status":"publish","type":"post","link":"https:\/\/wildow.com\/?p=1368","title":{"rendered":"Using Robocopy to delete old files from folder"},"content":{"rendered":"<h3 class=\"post-title entry-title\">Using Robocopy to delete old files from folder<\/h3>\n<div class=\"post-header\"><\/div>\n<div id=\"post-body-5979796655665300825\" class=\"post-body entry-content\">There are numerous occasions where you may want to keep a folder tidy and remove older files.We needed a solution for a shared folder that we wanted to control so that users didn&#8217;t use it as a lazy dumping ground for their files.<\/p>\n<p>After a bit of searching I found a novel way of using robocopy to accomplish exactly what we wanted.<\/p>\n<blockquote><p>mkdir c:\\delete<br \/>\nc:\\robocopy.exe c:\\Source c:\\Delete \/e \/MOVE \/MINAGE:14 \/LOG+:c:\\robocopy.log<br \/>\nrmdir c:\\delete \/s \/q<\/p><\/blockquote>\n<p>This script creates a folder called &#8216;delete&#8217;. Then uses robocopy to move files older than 14 days from the &#8216;source&#8217; folder to the &#8216;delete&#8217; folder. Lastly it deletes the &#8216;delete&#8217; folder so that only files newer than 14 days is left in the &#8216;source&#8217; folder.<\/p>\n<p>Notes:<br \/>\nRemember to change the location of the robocopy executable, robocopy.log, your source and delete folders.<br \/>\nAdd &#8216;\/XF [filename]&#8217; to the robocopy line in order to exclude one or more files from being deleted (if required).<\/p>\n<p>Original article can be found <a href=\"http:\/\/web.mac.com\/mjlucas62\/iWeb\/16475EB9-D054-43A3-A1AF-A633483D5ADE\/E9FBE28B-D970-477E-9603-BC0F7749E49A\/BEAFDF94-FBA8-4DFA-97EF-FCEA606CE613.html\">here<\/a>. (Pure genius!)<\/p>\n<\/div>\n<p><span class=\"post-author vcard\"> Posted by <span class=\"fn\"> <a class=\"g-profile\" title=\"author profile\" href=\"http:\/\/www.blogger.com\/profile\/14712061509750386357\" rel=\"author\" data-gapiattached=\"true\" data-onload=\"true\" data-gapiscan=\"true\"> Sony <\/a> <\/span> <\/span> <span class=\"post-timestamp\"> at <a class=\"timestamp-link\" title=\"permanent link\" href=\"http:\/\/www.codesingh.com\/2009\/08\/using-robocopy-to-delete-old-files-from.html\" rel=\"bookmark\"><abbr class=\"published\" title=\"2009-08-31T21:51:00+01:00\">21:51<\/abbr><\/a> <\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Using Robocopy to delete old files from folder There are numerous occasions where you may want to keep a folder tidy and remove older files.We needed a solution for a shared folder that we wanted to control so that users &#8230; <a class=\"more-link\" href=\"https:\/\/wildow.com\/?p=1368\">Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-1368","post","type-post","status-publish","format-standard","hentry","category-scripting"],"_links":{"self":[{"href":"https:\/\/wildow.com\/index.php?rest_route=\/wp\/v2\/posts\/1368","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wildow.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wildow.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wildow.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wildow.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1368"}],"version-history":[{"count":2,"href":"https:\/\/wildow.com\/index.php?rest_route=\/wp\/v2\/posts\/1368\/revisions"}],"predecessor-version":[{"id":1370,"href":"https:\/\/wildow.com\/index.php?rest_route=\/wp\/v2\/posts\/1368\/revisions\/1370"}],"wp:attachment":[{"href":"https:\/\/wildow.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1368"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wildow.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1368"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wildow.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1368"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}