且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

powershell - 连接 N 个文本文件并将文件名添加到每一行

更新时间:2023-08-29 08:46:46

试试这个:

$path = "c:\temp"
$out  = "c:\temp\output.txt"

Get-ChildItem $path -Filter data*.txt | % {
    $file = $_.Name
    Get-Content $_.FullName | % {
        "${file}: $_" | Out-File -Append $out
    }
}