Search and replace text in files of folder

Recently I have to shift this website from HTTP to HTTPS.This shift was because of change in Google Search Algorithm.In case you are interested in details of Google Search Algorithm update read this post.Due to this change I have to replace the text from many of my files with the new text

One option was to manually search the text in each file and then replace it one by one.This was easy approach but time consuming.I was looking for a way to search and replace the text in all files.All the files were in a single folder.So anything which can search the folder and replace the text will do the job.

I was planning to write a script for this purpose.The automated process will not have any manual error and will be less time consuming.I had around 50 odd files to work on.But before getting on to develop something from scratch it is better to look for an option available.There are some paid software available for this purpose.

Google search does not help much.As this was basic task I was not willing to spend money on it.Luckily I found one free open source software.I was already using it for quite sometime.But I was not aware that it can be used for this task.I was working on a file and while working I noticed this feature.After solving my problem I thought to share the same with others.

The software is Notepad++.It is free to download and use.I use it as an Text Editor and for coding purpose.It supports syntax highlighting feature for lots of programming languages.You can download it from this link.The process mentioned here will work with most of the file types.It will work for txt files,HTML files and other programming languages files.I used the process to search and replace text in multiple HTML files.

Now lets assume that you have a folder XYZ.You want to replace a certain text Time with Money in all files or multiple files in that folder.So after installing Notepad++ open any one of the file in it.After opening the file in Notepad++ press CTRL + F together.This is standard find keyboard command.

You will see a new pop up window as shown below.Now lets understand different options of below window.

Search Replace Text Files in Folders Notepad++
Search Replace Text Files in Folders Notepad++

Find What

Enter the text you want to search for in the file.

Replace With

Enter the text with which you want to replace the above text in all the files.


Filter option is used if you do not want to search and replace the text in all files of the folder.Lets understand this with couple of examples.You have few text files few html files in the folder.You want to replace text A with B in all html files in the folder.Then in filter you will have to enter *.html.

Note by default it has *.* entry.This means search all files with all extensions.Now if you want to search files with file name starting with Test then filter value will become Test*.*

The character * is used to match all character words or numbers.If you want to search and replace all files with Test at the end of it then the filter will be *Test.*


You can select the folder you want search and replace the text in.You can browse for the folder.You can also use Follow current doc option.This option is described in details later on.

Match whole word only

If you select this option then whole word you entered will be matched for.

Match case

By default the search made is case insensitive.That is lowercase and uppercase letters are treated the same.For example test and Test will be treated same.Be selecting this option you make sure search is case sensitive.Lowercase letters are matched with lowercase letters only.So Test and test will be treated different.

Search Mode

Search Mode has three options.The first mode is Normal.Normal mode is the default mode.This is the option you will need most of the times.Extended search mode includes new line,tabs and other special characters in search.Most of the times you will not use this feature.This is for advanced users.Regular Expression support makes it very powerful.

Regular expression makes it possible to search for a pattern.For example you want to search for all images file names in your files.Then in this case .jpg will be same in all file names.But name of the files will change.In this case normal search mode will not be helpful.Regular expressions will work in this case.You can set the search mode to Regular expression and enter the regular expression in Find What text box.

Follow current doc

You have opened file A.The file is located in folder X.Now you want to search and replace text in all files of this folder.Then you need to select this option.It sets the directory to the folder of which you currently have the file open.

If you have opened file from different folder and want to search different folder then you should not select this option.You can also select folder using the directory option.You can use any of the two options to locate the folder.

In all sub folder

Your folder may have many sub folders.It depends on your requirement whether you want to search sub folders or not.If you want to search sub folders then you should select this option.If you do not want to search sub folders then leave this option blank.It is better to browse the sub folders and see if there is no risky file in there.You should use this option with caution.

In hidden folders

Hidden folders are one which you cannot see by default.By default many system files under Windows are hidden so that users can not accidentally make changes in those files.The files you create are not hidden by default.So select this option with case.If you have files under C directory then you should not select this option.
After selecting the options as per your requirement you can click on option Replace in Files to make the changes.


Notepad++ is an excellent software.It is one must have software in your kitty.I use it for PHP development,Python development and working with my text and HTML files.Most of the posts are written on Notepad++ and then copied here.I will advise you to try it once.

Leave a Comment