Page 1 of 1

Adding a Line to a File

Posted: Fri Oct 19, 2012 8:11 am
by scriptnoob
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

Posted: Fri Oct 19, 2012 10:18 am
by jvierra
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.