在Powershell群里?有群友问过这个问题:
$filepath = "E:\FormateFile"$DestFile = "E:\FormateFile\comb.txt"
if (Test-Path $DestFile){
Remove-Item $DestFile -Force -Confirm:$false
}
Get-ChildItem -Path $filepath -Include *.txt | ForEach-Object {
$fname = $_.Name
$content = Get-Content $fname
for ($i = 1 $i -lt $content.Length-1 $i++) {
Add-Content -Path $DestFile -Value "$fname,$content[$i]"
}
}
$test=gc "1.txt"$test+=gc "2.txt"
$test+=gc "3.txt"
$test|Export-Csv "new.csv" -notype -Encoding oem
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)