How to simultaneously add data in all files using PowerShell

In the earlier post on Powershell,I had shown how to simultaneously open all the files of similar extension type within a given folder.

This naturally leads us to the extension – if we can open all the files at same time,is there any way we can write to those files too all in one go?

The answer is a definite yes through the wonders of PowerShell.

For example purposes,I have 3 txt files named a1.txt,a2.txt and a3.txt all residing in one folder named texts in D: drive.So the full path is D:texts which is the same scenario as in earlier post.

Suppose I want to append some text to all of the above 3 files simultaneously,it becomes ridiculously simple to do so using PowerShell.

Open PowerShell.(Start > Run> powershell or simply type in powershell in search box within Start Menu).

Type : Add-Content d:texts*.txt “Welcome”





What this will do is get the command Add-Context to append text mentioned within the quotes (Welcome) in this case to all the .txt files specified in the particular folder.

Here is what is seen once the above command is run :

All the 3 text files have been updated with single word Welcome as mentioned in the command.

I am pretty sure one can come up with many ways to avoid tedious data processing on multiple files using the above command within PowerShell.

Advertisement

One Response to “How to simultaneously add data in all files using PowerShell”

  1. John Watson
    May 8, 2018 at 10:03 am #

    EdbMails Offline EDB to PST Converter provides the best way to export Dismounted/Offline EDB file to PST File format. EdbMails exports mailbox data like inbox, sent items, calendar, contact, attachment, journal, task etc. It also performs Offline EDB to MSG, HTML, EML. The tool has an ability to migrate office 365 and live exchange server migration. Convert EDB to PST Software has filter option like before and after date, From and To address, attachment and Subject.

    For more information visit: https://www.edbmails.com

Leave a Comment