Adding a Line to a File

Anything VBScript-related, including Windows Script Host, WMI, ADSI, and more.
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.
This topic is 11 years and 5 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
scriptnoob
Posts: 1
Last visit: Fri Oct 19, 2012 11:41 am

Adding a Line to a File

Post 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.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Adding a Line to a File

Post 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.
This topic is 11 years and 5 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked