How to Change HTML Code in Multiple Files at Once

Did you know that you can edit multiple HTML files and replace the same text they contain at once? In this tutorial I will demonstrate how to do that.

While working with HTML files or any other type of text file, it is possible that you may need to replace or remove the same piece of text (or code) from multiple files. There have been occasions where I needed to edit multiple HTML files during my design and development activities. At first, I was doing it manually, via doing the same action repeatedly on each file but then I found a much simpler way to do the same thing and I will share it with you below.

If you need to make changes in only a couple of files, it won't be a problem since it wouldn't take much of your time to manually find and replace/remove that specific code in a few files. However, if you have dozens or hundreds of files that need the exact same modification, you'd better use a tool to do that for you with the push of a button.

Some of the text editing tools allow multiple file editing and I will to demonstrate how to do that using a free text editor, Notepad++.

I use Notepad++ for all of my coding related work including editing HTML files, except the old Notepad for taking some quick notes. It is a really nice tool with a lot of features and I highly recommend it if you haven't tried it yet.

How to Edit Multiple HTML Files with Notepad++

Step 1: Open Notepad++.

Step 2: Press Ctrl+Shift+F buttons to open Find in Files window. You can also do that from the top menu: Search > Find in Files.

How to Change HTML Code in Multiple Files at Once

Step 3: Locate the folder that contains the files you want to edit using the "..." button to the right of the Directory field. In my example, I used a test folder located in C:\\User\\Projects\\Test\\.

Step 4: Fill the Find what field with the target text that you want to change and Replace with field with the text you want to insert.

Step 5: Click on the Replace in Files button and all the files in the folder will be updated immediately.

As you will notice, there are additional options on the Find in Files window and I will briefly explain them.

- If you have files in sub-folders and you want to do the replacement in that files too, check In all sub-folders.
- If you need a case sensitive replacement, check Match case.
- Use Filters if you want to filter the name or extension of the files that you want to make change, such as *.html to apply the changes to only HTML files.
- Check Regular expression if your replacement includes regular expressions.

You can find more detailed information about finding and replacing text in files with Notepad++ on this page.

f t g+ in