我正在嘗試製作文件屬性列表和文件中第一行的內容。使用Get-ChildItem和Get-Content
命令:
get-ChildItem -Recurse *.txt | select-object Name, DirectoryName, Length
給我的名,目錄名,並在每個目錄中的文件的lengh。
我還需要第一行的內容以及每個* .txt文件的行數。最後,所有的信息應該在一個CSV文件中。我怎樣才能做到這一點?
例子:
File_01.txt, C:\folder, 243, Text of the first line of the File_01.txt, number of lines in File_01.txt
File_02.txt, C:\folder, 290, Text of the first line of the File_02.txt, number of lines in File_02.txt
File_03.txt, C:\folder, 256, Text of the first line of the File_03.txt, number of lines in File_03.txt
謝謝!這對我來說非常合適。 我試圖過濾文件的結果,其中包含字符串「Transaction Report」。 管道: '| | where-object {$ _ | select-string -pattern「Transaction Report」-eq $ true}' 因爲找不到匹配參數名稱「eq」的位置參數。我如何根據字符串模式來對這些文件進行歸檔? – Ron
歡迎Ron。請考慮接受答案。另外,請開始一個新的問題 –