乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      Powershell

       xiaozhuang 2019-05-28

      日常工作中我們往往有需要導出當前共享環(huán)境或磁盤文件目錄層級結構等的需求,最早在目錄少的情況下我們使用CMD下tree 命令可以很清晰的看到目錄、文件層級結構,那么我們又如何通過powershell直觀顯示或導出某文件目錄或盤符目錄層級結構呢?

      DOS下查看目錄、文件結構:

      tree /?
      以圖形顯示驅動器或路徑的文件夾結構。
      TREE [drive:][path] [/F] [/A]
      /F   顯示每個文件夾中文件的名稱。
      /A   使用 ASCII 字符,而不使用擴展字符。

      image


      Powershell查看目錄、文件結構:

      其實我們通過powershell命令也可以搭配tree命令使用,簡單操作如下:

      Get-ChildItem D:\SW_Office_Plus |tree /f
      Get-ChildItem D:\SW_Office_Plus |tree /A

      Get-ChildItem :獲取一個或多個指定位置中的項和子項。

      獲取當前目錄下文件夾名稱:

      Get-ChildItem D:\SW_Office_Plus | ?{$_.psiscontainer -eq $true}

      獲取當前目錄下文件名稱:
      Get-ChildItem D:\SW_Office_Plus | ?{$_.psiscontainer -eq $false}

      image

      接下來進入我們今天的主題內容,如何查看當前目錄下文件層級,具體命令如下:

      Get-ChildItem -Recurse -Directory -Depth 3 |select FullName

      Get-ChildItem D:\SW_Office_Plus  -Recurse -Directory -Depth 3 |select Fullname

      image

      如果需要對結果進行導出,可通過如下命令操作:

      Get-ChildItem -Recurse -Directory -Depth 3 |select FullName | Export-Csv d:\fullname.csv -Encoding UTF8 –NoTypeInformation

      PS.補充:導出文件、文件目錄名稱、創(chuàng)建時間、格式等等信息:

      Get-ChildItem -Path D:\SW_Office_Plus -Recurse |`
      foreach{
      $Item = $_
      $Type = $_.Extension
      $Path = $_.FullName
      $ParentS = ($_.Fullname).split("\")
      $Parent = $ParentS[@($ParentS.Length - 2)]
      $ParentPath = $_.PSParentPath
      $ParentPathSplit = ($_.PSParentPath).split("::")
      $ParentPathFinal = $ParentPathSplit[@($ParentPathSplit.Length -1)]
      #$ParentPath = [io.path]::GetDirectoryName($myDirectory)
      $Folder = $_.PSIsContainer
      $Age = $_.CreationTime
      $Path | Select-Object `
          @{n="Name";e={$Item}},`
          @{n="Created";e={$Age}},`
          @{n="Folder Name";e={if($Parent){$Parent}else{$Parent}}},`
          @{n="filePath";e={$Path}},`
          @{n="Extension";e={if($Folder){"Folder"}else{$Type}}},`
          @{n="Folder Name 2";e={if($Parent){$Parent}else{$Parent}}},`
          #@{n="Folder Path";e={$ParentPath}},`
          @{n="Folder Path 2";e={$ParentPathFinal}}`
      }| Export-Csv d:\Folder.csv -Encoding UTF8 -NoTypeInformation

      image

      導出后格式如下,可自行篩選,該腳本內容具體可參考該link。

      image

      歡迎關注微信公眾號:小溫研習社

        本站是提供個人知識管理的網(wǎng)絡存儲空間,所有內容均由用戶發(fā)布,不代表本站觀點。請注意甄別內容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權內容,請點擊一鍵舉報。
        轉藏 分享 獻花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多