2012-11-29 4 views
0

여기에 설명 된 코드를 내 케이스에 맞게 사용자 정의하려고합니다. PowerShell add text line to multiple files 번호가있는 CSV 파일이 여러 개 있고 첫 번째 줄에는 특정 문구 (예 : 강수량 파일)를 갖고 싶습니다. 내가 뭐하는 거지 다음 >powershell을 통해 여러 파일에 텍스트 추가

[email protected]" 
>"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" 
>} 

내가 잘못 가고 위치에 대한 어떤 생각? 정말 고마워요.

+0

무엇이 오류입니까? BTW는 코드를 확인합니다 : 2 행부터 시작해서 코드가 괜찮은 것 같은데 ...'Set-Content'를 제거했을 때의 결과는 무엇입니까? –

+0

foreach-object에있는 것 같습니다. 문제가''' –

+1

오류입니다 : 예기치 않은 토큰''n "+ (Get-Content $ _. FullName | Out-String) | Set-Content -P ath $ _. 줄에 : 2 문자 : 86 + $ header'n "+ (Get-Content $ _. FullName | Out-String) | Set-Content -Path $ _. F ullName"<<<< + CategoryInfo : ParserError : ('n "+ (Get-Cont ... th $ _. FullName": 문자열) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : UnexpectedToken – Mary

답변

0

도움을 주신 모든 분들께 감사드립니다. 나는 마침내 이것으로 작동합니다 :

[email protected]" 
catchment rainfall 
"@ 
Get-ChildItem .\testing\ -Recurse -Filter *.csv| Foreach-Object { $header+"`n"+ (Get-Content $_.FullName | Out-String) | Set-Content -Path $_.FullName} 
관련 문제