Do you ever want to search for files that contain keywords or specific strings of characters?
This article explains how to search a folder or subfolder for files that contain keywords or specific strings, and how to replace strings using the Sakura Editor.
Download Sakura Editor
You can download the latest version of Sakura Editor from the link below.
Download – Sakura Editor (sakura-editor.github.io)
Search for string or keyword with Grep
First, we will explain how to search for a specific string in files of a folder or subfolder using the Grep function.
1. click “Grep” from the “Search” tab of the Sakura Editor (shortcut: Ctrl+G)
2. enter search conditions
Enter the following information into the search conditions. (only frequently used criteria)
- Find what: String or keyword to be searched
(e.g.「 test1;test2」) - Filters: Name of the file or file extension to be searched
(e.g. 「*. txt」,「*.*」) - Look in: path of the folder you want to search
(e.g.「 C:\test」) - Excluded file: names of files to exclude
(e.g.「*.exe;*.obj;*.png」) - Exclude folder: Folders to exclude
(e.g.「 .git;.svn;.vs」) - Include subfolders: Check to search also from subfolders of folder
- Output each folder: Check to display search results by folder.
※Multiple can be entered separated by “;”.
In the capture, files containing the string “test” are searched from all folders under “C:\test”. However, files with the following extensions and the following folders are excluded from the search. Excluded file extensions: “msi, exe, obj, pdb, jlk, res, pch, jobs, ipdb”. Excluded folders: “git, svn, vs”.
By the way, “*” means any string. For example, “*.txt” means all strings ending in “.txt”. “hoge.txt”, “fuga.txt”, and “.txt” will all be hits.
3. search execution
Click “Find” to execute a search using the search conditions entered. If “Real Time View” is checked during the search, the search results will be displayed in real time.
The following results were displayed when searching with the current search conditions.
You will see a list of file path containing the string “test” in the search results.
String Replacement with Grep Replace
Next, we will discuss string replacement in Grep.
1. Click on “Grep Replace” from the “Search” tab in the Sakura Editor.
2. Enter replacement conditions
The following information is provided as an example.
- Find what: String to be replaced
(e.g.「 test1」) - Replace with: string to replace
(e.g. 「test2」) - Filters: Name of the searched file
(e.g.「*. txt」) - Look in: path of the folder you want to search
(e.g. 「C:\test」) - Excluded file: names of files to exclude
(e.g. 「*.exe;*.obj;*.png」) - Exclude folder: names of folders to exclude
(e.g.「.git;.svn;.vs」) - Include subfolders: Check to search from subfolders of “folder”.
- Output each folder: Check to search results are displayed by folder.
※Multiple inputs can be entered for files, folders, excluded file and excluded folder separated by “;”.
In the capture, condition searches for files containing the string “test” in all folders under “C:\test” and replaces it with the string “test2”. However, files with the following extensions and the following folders are excluded from the search. Excluded file extensions: “msi, exe, obj, pdb, jlk, res, pch, jobs, ipdb”. Excluded folders: “git, svn, vs”.
3. replace execution
Click “Replace” to execute replacements with the conditions you entered.
When the replacement is complete, the replaced parts are listed.
Key points of this article
Sakura Editor’s Grep function allows you to batch search and string replace files in folders and subfolders by specific strings or keywords.
More various, sakura editor’s articles are posted elsewhere, so check back if you have time! 👇👇👇👇👇