{"id":832,"date":"2017-02-16T13:04:37","date_gmt":"2017-02-16T13:04:37","guid":{"rendered":"http:\/\/sccm.haas.se\/?p=832"},"modified":"2017-02-16T13:04:37","modified_gmt":"2017-02-16T13:04:37","slug":"list-all-subfolders-but-only-one-level-deep-in-a-directory","status":"publish","type":"post","link":"http:\/\/sccm.haas.se\/?p=832","title":{"rendered":"List all subfolders, but only one level deep in a directory."},"content":{"rendered":"<p>I&#8217;m just putting this here because I was so satisfied that I could do this with one line in Powershell instead of a whole lot more in DOS or VBScript.<\/p>\n<p>List all subfolders in a folder with a depth of\u00a0one (all folders only\u00a0in the first level of a directly)\u00a0to a file and sort everything nicely. You need Powershell v5 or you&#8217;ll get an error from some of the parameters.<\/p>\n<pre><span style=\"color: #3366ff;\">Get-ChildItem<\/span><span style=\"color: #0000ff;\"> -Directory<\/span> <span style=\"color: #0000ff;\">-Path<\/span> <span style=\"color: #ff0000;\">\"C:\\temp\"<\/span> <span style=\"color: #0000ff;\">-Recurse -Depth<\/span> 1 <span style=\"color: #0000ff;\">-name<\/span> | <span style=\"color: #3366ff;\">Sort-Object |fl | Out-File<\/span> <span style=\"color: #0000ff;\">-FilePath<\/span> <span style=\"color: #ff0000;\">\"c:\\temp\\test.txt\"<\/span><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m just putting this here because I was so satisfied that I could do this with one line in Powershell instead of a whole lot more in DOS or VBScript. List all subfolders in a folder with a depth of\u00a0one (all folders only\u00a0in the first level of a directly)\u00a0to a file and sort everything nicely.<\/p>\n<p class=\"text-right\"><span class=\"screen-reader-text\">Continue Reading&#8230; List all subfolders, but only one level deep in a directory.<\/span><a class=\"btn btn-secondary continue-reading\" href=\"http:\/\/sccm.haas.se\/?p=832\">Continue Reading&#8230;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[48],"_links":{"self":[{"href":"http:\/\/sccm.haas.se\/index.php?rest_route=\/wp\/v2\/posts\/832"}],"collection":[{"href":"http:\/\/sccm.haas.se\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/sccm.haas.se\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/sccm.haas.se\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/sccm.haas.se\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=832"}],"version-history":[{"count":2,"href":"http:\/\/sccm.haas.se\/index.php?rest_route=\/wp\/v2\/posts\/832\/revisions"}],"predecessor-version":[{"id":834,"href":"http:\/\/sccm.haas.se\/index.php?rest_route=\/wp\/v2\/posts\/832\/revisions\/834"}],"wp:attachment":[{"href":"http:\/\/sccm.haas.se\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=832"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/sccm.haas.se\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=832"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/sccm.haas.se\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=832"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}