我正在嘗試通過在檔案夾中附加多個檔案來創建單個檔案。在檔案之間我想添加一個換行符。我已經嘗試了以下方法,但它不起作用。請建議我錯過了什么。
Get-ChildItem -Filter *.sql |sort CreationTime| % { Get-Content $_ -ReadCount 0 | Add-Content combined_files.sql| Add-Content combined_files.sql -value `n"dummy text before next file" }
我能夠獲得使用子檔案的內容創建的 combine_files.sql,但檔案之間的文本丟失。請建議。
uj5u.com熱心網友回復:
在寫出資料之前嘗試構建資料
Get-ChildItem -Filter *.sql | Sort-Object CreationTime | ForEach-Object {
$ThisFile = (Get-Content $_.FullName) "`ndummy text before next file"
Add-Content -Path combined_files.sql -Value $Thisfile
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/416694.html
標籤:
