{"id":875,"date":"2014-09-19T00:04:18","date_gmt":"2014-09-19T00:04:18","guid":{"rendered":"http:\/\/elbsolutions.com\/projects\/?p=875"},"modified":"2022-02-03T11:25:00","modified_gmt":"2022-02-03T17:25:00","slug":"drive-space-getting-automate","status":"publish","type":"post","link":"https:\/\/elbsolutions.com\/projects\/drive-space-getting-automate\/","title":{"rendered":"Drive Space getting you down &#8211; automate it&#8230;"},"content":{"rendered":"<p>Drive Space for local backups (local mean QUICK backups) can get\u00a0ownerous and it constantly needs user interaction. Well lets put a stop to that and fullfill a dream I have.<\/p>\n<ol>\n<li>a) cull either on a date or file limit basis<\/li>\n<li>b) cull rules are to keep<\/li>\n<\/ol>\n<ul>\n<li>last item in the year<\/li>\n<li>last item in the month<\/li>\n<li>last day in the week<\/li>\n<li>last hour in the day<\/li>\n<\/ul>\n<p>So a way to start is to simply<\/p>\n<ul>\n<li>make a file list<\/li>\n<li>mark the end of all the years, months, weeks, days and hours<\/li>\n<li>delete all else until our time or date criteria is met<\/li>\n<\/ul>\n<p>Lets get going &#8230;<!--more--> Now in real life, there will be 2 criteria &#8211; lets say 2 limits &#8211; an in between these limits<\/p>\n<ul>\n<li>we move the files to another location B instead of deleting them<\/li>\n<li>then the delete criteria will be on location B or \u00a0&#8211; rerun the whole thing and perform a \u00a0delete on B but a move on the initial location<\/li>\n<\/ul>\n<p>To be safe, I will either make a text output or if I am smart &#8211; \u00a0a bat file output &#8211; that if required will be easy to run if I like it. THen wrap the whole thing up in a .bat file and schedule it. Remember I<a title=\"Windows Task Scheduler \u2013 a consistent way to execute exe files\" href=\"http:\/\/elbsolutions.com\/projects\/windows-task-scheduler-a-consistent-way-to-execute-exe-files\/\" target=\"_blank\" rel=\"noopener noreferrer\"> have an article on running .exe programs from the scheduler that will be required<\/a>.<\/p>\n<p>A <a href=\"http:\/\/pinvoke.net\/default.aspx\/kernel32.GetDiskFreeSpaceEx\" target=\"_blank\" rel=\"noopener noreferrer\">site\u00a0that mentions<\/a> an old way to do it &#8211; but this was .net 2.0 (<a href=\"http:\/\/support.microsoft.com\/kb\/225144\/en-us\" target=\"_blank\" rel=\"noopener noreferrer\">see msdn kb article too<\/a>). Since I am doing this on a local machine &#8211; this is overkill. \u00a0They recommend <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/system.io.driveinfo(v=vs.110).aspx\" target=\"_blank\" rel=\"noopener noreferrer\">DriveInfo <\/a>and lets see what it has now that we are .net 4.5. We are going to NOT worry about disk quotas etc- so we will be looking at the DriveInfo.TotalFreeSpec<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Drive Space for local backups (local mean QUICK backups) can get\u00a0ownerous and it constantly needs user interaction. Well lets put a stop to that and fullfill a dream I have. a) cull either on a date or file limit basis b) cull rules are to keep last item in the year last item in the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-875","post","type-post","status-publish","format-standard","hentry","category-general"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Drive Space getting you down - automate it... - ELB Solutions.com Inc.<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/elbsolutions.com\/projects\/drive-space-getting-automate\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Drive Space getting you down - automate it... - ELB Solutions.com Inc.\" \/>\n<meta property=\"og:description\" content=\"Drive Space for local backups (local mean QUICK backups) can get\u00a0ownerous and it constantly needs user interaction. Well lets put a stop to that and fullfill a dream I have. a) cull either on a date or file limit basis b) cull rules are to keep last item in the year last item in the [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/elbsolutions.com\/projects\/drive-space-getting-automate\/\" \/>\n<meta property=\"og:site_name\" content=\"ELB Solutions.com Inc.\" \/>\n<meta property=\"article:published_time\" content=\"2014-09-19T00:04:18+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-02-03T17:25:00+00:00\" \/>\n<meta name=\"author\" content=\"Etienne Bley\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Etienne Bley\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/drive-space-getting-automate\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/drive-space-getting-automate\\\/\"},\"author\":{\"name\":\"Etienne Bley\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#\\\/schema\\\/person\\\/51e717c68f4f5917c63baf88f0896c39\"},\"headline\":\"Drive Space getting you down &#8211; automate it&#8230;\",\"datePublished\":\"2014-09-19T00:04:18+00:00\",\"dateModified\":\"2022-02-03T17:25:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/drive-space-getting-automate\\\/\"},\"wordCount\":300,\"articleSection\":[\"General\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/drive-space-getting-automate\\\/\",\"url\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/drive-space-getting-automate\\\/\",\"name\":\"Drive Space getting you down - automate it... - ELB Solutions.com Inc.\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#website\"},\"datePublished\":\"2014-09-19T00:04:18+00:00\",\"dateModified\":\"2022-02-03T17:25:00+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#\\\/schema\\\/person\\\/51e717c68f4f5917c63baf88f0896c39\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/drive-space-getting-automate\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/drive-space-getting-automate\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/drive-space-getting-automate\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Drive Space getting you down &#8211; automate it&#8230;\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#website\",\"url\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/\",\"name\":\"ELB Solutions.com Inc.\",\"description\":\"Bringing all your IT Pieces together\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#\\\/schema\\\/person\\\/51e717c68f4f5917c63baf88f0896c39\",\"name\":\"Etienne Bley\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g\",\"caption\":\"Etienne Bley\"},\"url\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/author\\\/etienne-bley\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Drive Space getting you down - automate it... - ELB Solutions.com Inc.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/elbsolutions.com\/projects\/drive-space-getting-automate\/","og_locale":"en_US","og_type":"article","og_title":"Drive Space getting you down - automate it... - ELB Solutions.com Inc.","og_description":"Drive Space for local backups (local mean QUICK backups) can get\u00a0ownerous and it constantly needs user interaction. Well lets put a stop to that and fullfill a dream I have. a) cull either on a date or file limit basis b) cull rules are to keep last item in the year last item in the [&hellip;]","og_url":"https:\/\/elbsolutions.com\/projects\/drive-space-getting-automate\/","og_site_name":"ELB Solutions.com Inc.","article_published_time":"2014-09-19T00:04:18+00:00","article_modified_time":"2022-02-03T17:25:00+00:00","author":"Etienne Bley","twitter_misc":{"Written by":"Etienne Bley","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/elbsolutions.com\/projects\/drive-space-getting-automate\/#article","isPartOf":{"@id":"https:\/\/elbsolutions.com\/projects\/drive-space-getting-automate\/"},"author":{"name":"Etienne Bley","@id":"https:\/\/elbsolutions.com\/projects\/#\/schema\/person\/51e717c68f4f5917c63baf88f0896c39"},"headline":"Drive Space getting you down &#8211; automate it&#8230;","datePublished":"2014-09-19T00:04:18+00:00","dateModified":"2022-02-03T17:25:00+00:00","mainEntityOfPage":{"@id":"https:\/\/elbsolutions.com\/projects\/drive-space-getting-automate\/"},"wordCount":300,"articleSection":["General"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/elbsolutions.com\/projects\/drive-space-getting-automate\/","url":"https:\/\/elbsolutions.com\/projects\/drive-space-getting-automate\/","name":"Drive Space getting you down - automate it... - ELB Solutions.com Inc.","isPartOf":{"@id":"https:\/\/elbsolutions.com\/projects\/#website"},"datePublished":"2014-09-19T00:04:18+00:00","dateModified":"2022-02-03T17:25:00+00:00","author":{"@id":"https:\/\/elbsolutions.com\/projects\/#\/schema\/person\/51e717c68f4f5917c63baf88f0896c39"},"breadcrumb":{"@id":"https:\/\/elbsolutions.com\/projects\/drive-space-getting-automate\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/elbsolutions.com\/projects\/drive-space-getting-automate\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/elbsolutions.com\/projects\/drive-space-getting-automate\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/elbsolutions.com\/projects\/"},{"@type":"ListItem","position":2,"name":"Drive Space getting you down &#8211; automate it&#8230;"}]},{"@type":"WebSite","@id":"https:\/\/elbsolutions.com\/projects\/#website","url":"https:\/\/elbsolutions.com\/projects\/","name":"ELB Solutions.com Inc.","description":"Bringing all your IT Pieces together","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/elbsolutions.com\/projects\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/elbsolutions.com\/projects\/#\/schema\/person\/51e717c68f4f5917c63baf88f0896c39","name":"Etienne Bley","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g","caption":"Etienne Bley"},"url":"https:\/\/elbsolutions.com\/projects\/author\/etienne-bley\/"}]}},"_links":{"self":[{"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/posts\/875","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/comments?post=875"}],"version-history":[{"count":2,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/posts\/875\/revisions"}],"predecessor-version":[{"id":2786,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/posts\/875\/revisions\/2786"}],"wp:attachment":[{"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/media?parent=875"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/categories?post=875"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/tags?post=875"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}