Adding a Line to a File
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
- scriptnoob
- Posts: 1
- Last visit: Fri Oct 19, 2012 11:41 am
Adding a Line to a File
I am looking for a script to look in a folder and read each text file and check for a line. If it doesn't exist add that line to the beginning of the file, and if it does skip to the next file.
Adding a Line to a File
Can you post your script?
What is it that is not working?
We do not write customcritps butyou can ask a question about any aspect of script writing.
In PowerSehll you can
$line='My line of text'
dir c:folder* |
?{select-string $_ $line |
%{
$line |
Out-File $_ -append
}
This would do what you are after.
What is it that is not working?
We do not write customcritps butyou can ask a question about any aspect of script writing.
In PowerSehll you can
$line='My line of text'
dir c:folder* |
?{select-string $_ $line |
%{
$line |
Out-File $_ -append
}
This would do what you are after.