{"id":1393,"date":"2017-09-05T11:48:23","date_gmt":"2017-09-05T14:48:23","guid":{"rendered":"http:\/\/www.franklinjr.com\/blog\/?p=1393"},"modified":"2017-09-05T11:48:23","modified_gmt":"2017-09-05T14:48:23","slug":"apagar-arquivos-antigos-e-diretorios-vazios-com-powershell","status":"publish","type":"post","link":"https:\/\/www.franklinjr.com\/blog\/index.php\/2017\/09\/05\/apagar-arquivos-antigos-e-diretorios-vazios-com-powershell\/","title":{"rendered":"Apagar arquivos antigos e diret\u00f3rios vazios com powershell"},"content":{"rendered":"<p>Apagar arquivos com mais de 31 dias<br \/>\n<strong>Substitua %diretorio% pelo diret\u00f3rio que deseja apagar o conte\u00fado antigo<\/strong><\/p>\n<pre lang=\"powershell\">Get-ChildItem %diretorio% -recurse | Where {!$_.PSIsContainer -and $_.LastWriteTime -lt (get-date).AddDays(-31)} | Remove-Item -whatif\r\n<\/pre>\n<p>Apagar diret\u00f3rios vazios<br \/>\n<strong>Substitua %diretorio% pelo diret\u00f3rio que deseja apagar os diret\u00f3rios vazios<\/strong><\/p>\n<pre lang=\"powershell\">Get-ChildItem %diretorio% -recurse | Where {$_.PSIsContainer -and @(Get-ChildItem -Lit $_.Fullname -r | Where {!$_.PSIsContainer}).Length -eq 0} |Remove-Item -recurse -whatif\r\n<\/pre>\n<p>Lembrando que o par\u00e2metro -whatif no final simula o que aconteceria se o comando fosse realmente executado. Para ele ser realmente executado, remova o -whatif do final<\/p>\n<p>Refer\u00eancia:\u00a0<a href=\"https:\/\/stackoverflow.com\/questions\/1575493\/how-to-delete-empty-subfolders-with-powershell\">https:\/\/stackoverflow.com\/questions\/1575493\/how-to-delete-empty-subfolders-with-powershell<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Apagar arquivos com mais de 31 dias Substitua %diretorio% pelo diret\u00f3rio que deseja apagar o conte\u00fado antigo Get-ChildItem %diretorio% -recurse | Where {!$_.PSIsContainer -and $_.LastWriteTime -lt (get-date).AddDays(-31)} | Remove-Item -whatif Apagar diret\u00f3rios vazios Substitua %diretorio% pelo diret\u00f3rio que deseja apagar os diret\u00f3rios vazios Get-ChildItem %diretorio% -recurse | Where {$_.PSIsContainer -and @(Get-ChildItem -Lit $_.Fullname -r | [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[553,51],"tags":[594,577,609,435],"class_list":["post-1393","post","type-post","status-publish","format-standard","hentry","category-power-shell","category-windows","tag-automatizacao","tag-powershell","tag-ps","tag-script"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\r\n<title>Apagar arquivos antigos e diret\u00f3rios vazios com powershell - Franklin Jr.<\/title>\r\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\r\n<link rel=\"canonical\" href=\"https:\/\/www.franklinjr.com\/blog\/index.php\/2017\/09\/05\/apagar-arquivos-antigos-e-diretorios-vazios-com-powershell\/\" \/>\r\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.franklinjr.com\\\/blog\\\/index.php\\\/2017\\\/09\\\/05\\\/apagar-arquivos-antigos-e-diretorios-vazios-com-powershell\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"In\u00edcio\",\"item\":\"https:\\\/\\\/www.franklinjr.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Apagar arquivos antigos e diret\u00f3rios vazios com powershell\"}]}]}<\/script>\r\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Apagar arquivos antigos e diret\u00f3rios vazios com powershell - Franklin Jr.","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:\/\/www.franklinjr.com\/blog\/index.php\/2017\/09\/05\/apagar-arquivos-antigos-e-diretorios-vazios-com-powershell\/","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"BreadcrumbList","@id":"https:\/\/www.franklinjr.com\/blog\/index.php\/2017\/09\/05\/apagar-arquivos-antigos-e-diretorios-vazios-com-powershell\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"In\u00edcio","item":"https:\/\/www.franklinjr.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Apagar arquivos antigos e diret\u00f3rios vazios com powershell"}]}]}},"_links":{"self":[{"href":"https:\/\/www.franklinjr.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1393","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.franklinjr.com\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.franklinjr.com\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.franklinjr.com\/blog\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.franklinjr.com\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=1393"}],"version-history":[{"count":2,"href":"https:\/\/www.franklinjr.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1393\/revisions"}],"predecessor-version":[{"id":1395,"href":"https:\/\/www.franklinjr.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1393\/revisions\/1395"}],"wp:attachment":[{"href":"https:\/\/www.franklinjr.com\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=1393"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.franklinjr.com\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=1393"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.franklinjr.com\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=1393"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}