-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreplace-a-word-in-multiple-text-files-on-windows-10.html
More file actions
18 lines (18 loc) · 10.6 KB
/
Copy pathreplace-a-word-in-multiple-text-files-on-windows-10.html
File metadata and controls
18 lines (18 loc) · 10.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<!DOCTYPE html><html lang="en-gb"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Replace A Word In Multiple Text Files On Windows 10 - graphicdesigngeek.com</title><meta name="description" content="Text file editors like Notepad and Notepad++ are used to create lots of different types of files like subtitles, log files, batch files, PowerShell scripts,&hellip;"><meta name="generator" content="Publii Open-Source CMS for Static Site"><style>.copy-text{position:relative;padding:20px;padding-top:calc(16px * 2)!important;background-color:#403B3B;border-radius:5px;}.copy-icon{position:absolute;top:calc( 16px / 2);right:calc( 16px);cursor:pointer;display:flex;align-items:center;}.copy-icon svg{width:16px;stroke:#0885E7;}.copy-icon-text{margin-left:8px;font-size:0.75rem;color:#0885E7;}.copy-popup{position:absolute;top:50%;right:115%;transform:translateY(-50%);background-color:rgba(0,0,0,.8);color:#EB1111;padding:2px 6px;font-size:0.75rem;border-radius:4px;white-space:nowrap;}</style><link rel="canonical" href="https://graphicdesigngeek.com/replace-a-word-in-multiple-text-files-on-windows-10.html"><link rel="alternate" type="application/atom+xml" href="https://graphicdesigngeek.com/feed.xml" title="graphicdesigngeek.com - RSS"><link rel="alternate" type="application/json" href="https://graphicdesigngeek.com/feed.json" title="graphicdesigngeek.com - JSON"><meta property="og:title" content="Replace A Word In Multiple Text Files On Windows 10"><meta property="og:site_name" content="graphicdesigngeek.com"><meta property="og:description" content="Text file editors like Notepad and Notepad++ are used to create lots of different types of files like subtitles, log files, batch files, PowerShell scripts,&hellip;"><meta property="og:url" content="https://graphicdesigngeek.com/replace-a-word-in-multiple-text-files-on-windows-10.html"><meta property="og:type" content="article"><link rel="stylesheet" href="https://graphicdesigngeek.com/assets/css/style.css?v=26ea6dbd5f9804efdb1c0d7cabfef8b8"><script type="application/ld+json">{"@context":"http://schema.org","@type":"Article","mainEntityOfPage":{"@type":"WebPage","@id":"https://graphicdesigngeek.com/replace-a-word-in-multiple-text-files-on-windows-10.html"},"headline":"Replace A Word In Multiple Text Files On Windows 10","datePublished":"2026-07-27T18:43-04:00","dateModified":"2026-07-27T18:43-04:00","description":"Text file editors like Notepad and Notepad++ are used to create lots of different types of files like subtitles, log files, batch files, PowerShell scripts,…","author":{"@type":"Person","name":"admin","url":"https://graphicdesigngeek.com/authors/admin/"},"publisher":{"@type":"Organization","name":"admin"}}</script><noscript><style>img[loading] {
opacity: 1;
}</style></noscript></head><body class="post-template"><div class="container container--center"><header class="header"><div class="header__logo"><a class="logo" href="https://graphicdesigngeek.com/">graphicdesigngeek.com</a></div><nav class="navbar js-navbar"><button class="navbar__toggle js-toggle" aria-label="Menu" aria-haspopup="true" aria-expanded="false"><span class="navbar__toggle-box"><span class="navbar__toggle-inner">Menu</span></span></button><ul class="navbar__menu"><li><a href="https://graphicdesigngeek.com/" target="_self">Home</a></li><li><a href="https://graphicdesigngeek.com/" target="_self">Posts</a></li><li><a href="https://graphicdesigngeek.com/tags/comfyui/" target="_self">Comfyui</a></li><li><a href="https://graphicdesigngeek.com/tags/powershell/" target="_self">Powershell</a></li><li><a href="https://graphicdesigngeek.com/tags/minimax/" target="_self">Minimax</a></li><li><a href="https://graphicdesigngeek.com/tags/krea2/" target="_self">Krea2</a></li></ul></nav></header><main class="content"><article class="post"><header><h1 class="post__title">Replace A Word In Multiple Text Files On Windows 10</h1><div class="post__meta"><time datetime="2026-07-27T18:43" class="post__date">July 27, 2026 </time><span class="post__author"><a href="https://graphicdesigngeek.com/authors/admin/" class="feed__author">admin</a></span></div></header><div class="post__entry"><p>Text file editors like Notepad and Notepad++ are used to create lots of different types of files like subtitles, log files, batch files, PowerShell scripts, and more. Where a text file editor can create these files, it can also edit them. If you have a lot of text files, ones that have the TXT file extension and you need to replace a word, or several words in them you can do so with a PowerShell script. The script makes it so you don’t have to individually open each file and then replace the word. You can use this same script for other file types that can be created with a text file editor. Here’s how you can replace a word in multiple text files.</p><h2>Replace Word In Text Files</h2><p>First, you need to put all your text files in the same folder. The script will examine only one directory when it runs and not your entire system which is why you need all the files in one place.</p><p>Open a new Notepad file and paste the following in it.</p><pre>Get-ChildItem 'Path-to-files\*.txt' -Recurse | ForEach {
(Get-Content $_ | ForEach { $_ -replace 'Original-Word', 'New-Word' }) |
Set-Content $_
}</pre><p>You need to edit the above script. First, edit the ‘Path-to-files’ part with the actual path to the folder with all the text files in it. Second, replace the ‘Original-Word’ with the word you want to replace. Finally, replace the ‘New-Word’ with the word you want to replace the old one with. For example, I have a few text files that all have the word ‘Post’ in them. I want to replace the word Post with Article. This is what the script will look like once I’ve edited it to suit my scenario.</p><pre>Get-ChildItem 'C:\Users\fatiw\Desktop\notepad-files\*.txt' -Recurse | ForEach {
(Get-Content $_ | ForEach { $_ -replace 'Post', 'Article' }) |
Set-Content $_
}</pre><p>Once you’ve edited the script, save it with the ps1 file extension. Make sure you change the file type from text files to all files in Notepad’s save as dialog. Run the script and it will perform the replace function.</p><figure class="not-lazy alignnone size-full wp-image-278691"><picture><source type="image/webp" srcset="https://www.addictivetips.com/app/uploads/2018/08/replace-word-txt-file.webp"><source type="image/jpeg" srcset="https://www.addictivetips.com/app/uploads/2018/08/replace-word-txt-file-1.jpg"><img loading="lazy" src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAUACgMBEQACEQEDEQH/xAGiAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgsQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+gEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoLEQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2gAMAwEAAhEDEQA/AP7fP+FeeEmaV57PUp5JppZ5DJ4h1wLumYvIiot+AITIWZI33+WreUrCFUReSWU4OcpSlGo5Sbk/3+JSu97JVkkvJKy6aGXsabbdndu/xz/Lmsfx/fGj/gpFH4Y+MXxY8N2PwC0hrLw98S/Heh2bH4vfFe2LWuk+KdVsLdjbWOs2tlbkxW6HyLO1trWL/V28EMKpGv4lieMvY4jEUoZRhOSlXq04c1atKXLCpKMbyau3ZK76vU85qnd2pQ3fRPr3au/U/wD/2Q==" width="1247" height="600" decoding="async" fetchpriority="high" data-is-external-image="true"></picture></figure><p></p><p>If you want to use this same script for XML or LOG files, edit the file extension in the first line. For example,</p><p>This will become</p><pre>Get-ChildItem 'C:\Users\fatiw\Desktop\notepad-files\*.txt'</pre><p>This;</p><pre>Get-ChildItem 'C:\Users\fatiw\Desktop\notepad-files\*.xml'</pre><p>There is one thing you ought to know about this script; it doesn’t match words to words. If you’re looking to replace every occurrence of ‘the’ with ‘a’, it will also replace the ‘the’ at the start of ‘these’ and ‘there’. That is a shortcoming of this script. To work around it, you can use Notepad++ which has a match word option.</p><p> </p><p>https://www.addictivetips.com/windows-tips/replace-a-word-in-multiple-text-files-windows-10/</p></div><footer class="wrapper post__footer"><p class="post__last-updated">This article was updated on July 27, 2026</p><div class="post__share"></div></footer><nav class="pagination"><div class="pagination__title"><span>Read other posts</span></div><div class="pagination__buttons"><a href="https://graphicdesigngeek.com/useful-tips-for-datasets.html" class="btn previous" rel="prev" aria-label="[MISSING TRANSLATION]: useful tips for datasets "><span class="btn__icon">←</span> <span class="btn__text">useful tips for datasets</span> </a><a href="https://graphicdesigngeek.com/minimax-helpful-information.html" class="btn next" rel="next" aria-label="[MISSING TRANSLATION]: minimax helpful information "><span class="btn__text">minimax helpful information</span> <span class="btn__icon">→</span></a></div></nav></article></main><footer class="footer"><div class="footer__inner"><div class="footer__copyright"><p>© 2024 Powered by Publii CMS :: <a href="https://github.com/panr/hugo-theme-terminal" target="_blank" rel="noopener">Theme</a> ported by the <a href="https://getpublii.com/customization-service/" target="_blank" rel="noopener">Publii Team</a></p></div></div></footer></div><script defer="defer" src="https://graphicdesigngeek.com/assets/js/scripts.min.js?v=c2232aa7558e9517946129d2a1b8c770"></script><script>window.publiiThemeMenuConfig={mobileMenuMode:'sidebar',animationSpeed:300,submenuWidth: 'auto',doubleClickTime:500,mobileMenuExpandableSubmenus:true,relatedContainerForOverlayMenuSelector:'.top'};</script><script>var images = document.querySelectorAll('img[loading]');
for (var i = 0; i < images.length; i++) {
if (images[i].complete) {
images[i].classList.add('is-loaded');
} else {
images[i].addEventListener('load', function () {
this.classList.add('is-loaded');
}, false);
}
}</script><script>window.iconChoice = 1;window.iconSize = 16;window.iconColor = '#0885E7';window.txtLabel = 'Copy Text';window.txtMessage = 'Copied!';window.txtTime = 1500;</script><script src="https://graphicdesigngeek.com/media/plugins/copy-text/copyText.min.js" defer="defer"></script></body></html>