PowerShell - 附加多个文件时添加新行
PowerShell - Add new line when appending multiple files
我正在尝试通过在文件夹中附加多个文件来创建单个文件。在文件之间我想添加一个换行符。我已经尝试了以下但它不起作用。请建议我缺少什么。
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" }
我能够获得使用子文件内容创建的 combined_files.sql,但文件之间的文本丢失了。请提出建议。
尝试在写出数据之前构建数据
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
}
我正在尝试通过在文件夹中附加多个文件来创建单个文件。在文件之间我想添加一个换行符。我已经尝试了以下但它不起作用。请建议我缺少什么。
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" }
我能够获得使用子文件内容创建的 combined_files.sql,但文件之间的文本丢失了。请提出建议。
尝试在写出数据之前构建数据
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
}