通过PowerShell将文本添加到多个文件 [英] Add text to multiple files via powershell
本文介绍了通过PowerShell将文本添加到多个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试自定义此处描述的代码 PowerShell将文本行添加到多个文件
到我的case。我有多个csv文件只有数字,在第一行,我想有一个特定的短语(例如,集水区降雨量文件)。
我执行以下操作:
>
I am trying to customise the code described here PowerShell add text line to multiple files to my case. I have multiple csv files with numbers only and on the first line I would like to have a specific phrase (e.g catchment rainfall file). I am doing the following: >
$header=@"
>"catchment rainfall
>"@
>Get-ChildItem D:\Documents and Settings\mary\testing\mary00 -Recurse -Filter *.aspx | >Foreach-Object {
> $header`n" + (Get-Content $_.FullName | Out-String) | Set-Content -Path $_.FullName"
>}
我错了?
非常感谢。
Any thoughts on where I am going wrong? Thanks so much.
推荐答案
感谢大家的帮助我终于想到了这个工程:
thanks everyone for their help. I have finally come up with this which works:
$header=@"
catchment rainfall
"@
Get-ChildItem .\testing\ -Recurse -Filter *.csv| Foreach-Object { $header+"`n"+ (Get-Content $_.FullName | Out-String) | Set-Content -Path $_.FullName}
这篇关于通过PowerShell将文本添加到多个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文