5

I'm looking for Windows software which can replace multiple text strings, in multiple files, at the same time.

I have some words which I want to replace in 1000's of text files. For example, I want to replace ab, abc, abcd, abcde, abcdef, abcdefg, abcdefgh.

I don't want to do it word by word (for example, using the Notepad++ Replace in files option with each replacement) - I want to replace all these words at the same time. I want to replace it with a common word; let's say "Hello".

Is there any software that can do this?

  • You can never replace all of the words in all of the files simultaneously just one file at a time, possibly very fast. This is due to the bottlenecks of reading the files from the disk, etc. – Steve Barnes May 27 '16 at 17:51
  • So ab gets replaced with Hello, and abc gets replaced with Hello etc? – Jan Doggen Jun 15 '16 at 12:54
6

You can do this with Notepad++ without opening your files:

  • Open Notepad++
  • Press Ctrl + H
  • Switch to the tab titled "Find in Files"
  • Specify your search text, and the replacement
  • Set the folder in which your files are
  • Depending on your needs, you might specify some filters on your files (ex: *.txt, *.html), you might check "in all subfolders", set the "search mode" etc.
  • Click "Replace in Files"

Be sure before you proceed to the final step though, because it's irreversible. You might want to click "Find All" first to check your matches.

It may take a while depending on the size and number of your files.

Replace in files using Regexp

  • Sorry for the late reply but please read my question again. I know how to do it with notepad++ but i can replace only one text at a time. For example, if i want to replace 100 different words, i should do this replacement 100 different times. What i asked is not that. I want to do this 100 word replacement in a single click – joe Jun 11 '16 at 2:51
  • Okay, I updated the screenshot to match the example you gave. You still can do this with the replace in files feature in notepad++ but you have to set the search mode to "Regular expression" and you have to format the regex pattern matching all of the strings you want to replace. So in your example you want to replace ab, abc, abcd, ... with "Hello", then your pattern would be "^(.*)ab[a-z]+(.*)$" (exclude the surronding quotes) and the replacement would be \1Hello\2 (\1 replaces the first string surrounded by () , \2 \ the second and so on). – Frank Linno WELL Jun 15 '16 at 12:48
2

You can use the Microsoft windows ports of GNU awk or sed, which are both CLI and open source. One commonly used port: http://gnuwin32.sourceforge.net/packages.html

  • Thanks Franck for the comment. Will try this too – joe Jun 11 '16 at 2:55
1

I have used free gsar to search or search/replace multiple files sequentially.

In your situation, it would roll through each set of search and replace criteria that you specify. I'd probably start with abcdefg, abcdef, abcde, etc. like others have said, backup your folder in case your work has undesired results.

I've used this tool in the past to:

  • change copyright year on web sites
  • change hex values for proper carriage return line feed in windows
  • look for non-ascii characters in files
  • Thanks a lot. will try. sorry for late reply – joe Jun 11 '16 at 2:54
1

It seems CudaText editor can do this. It is free, Windows/Linux. Plugin needed: "Find in Files" (it is in AddonManager in CudaText).

In "Find In Files" dialog, enter such string to search: (ab|def|fgfg) - this is regex, so check the option "Reg ex" (it is icon .* in dialog).

  • Thanks RP. I will try – joe Jun 11 '16 at 2:57
1

RProgram is rigth.

I'am author of plugin FindInFile (FiF) for CudaText editor.

  1. FiF indeed can do what you want. FiF

  2. FiF fills a report-file to show all found fragments and all replacements. Example report. "(!N)" marks line with found fragment, "(=N)" marks line with replacement. enter image description here

  3. In CudaText the report-file is alive. You can jump to replacment point in source file.

FiF-plugin is stable. See github.com/kvichans/cuda_find_in_files to get more info and to question.

  • Thanks kvichans. Will try this. – joe Jun 11 '16 at 2:54
0

Depending on the size of the files and your pc specs this should be possible with Notepad++.

  1. Open all files with Notepad++ (or just 200 or something, depending on your PC)
  2. CTRL + H
  3. Set find what to ab|abc|abcd|abcde|abcdef|abcdefg (whatever you are trying to replace, seperate with |. it is basic regex, i recommend looking that up)
  4. Set replace with to whatever you want (in your example Hello)
  5. Set Search Mode to "Regular Expression"
  6. Press replace all in all opened documents
  • 1
    The OP specifically said he didn't want to have to open all the files to do this - there are 1000s of them – Tim Malone May 27 '16 at 22:15
  • I don't want to open files. But if this work in opened files, i think it should work in fine in files too. isn't it? will try. Thanks for your comment. – joe Jun 11 '16 at 2:56
0

You may use Advanced Find and Replace software from http://www.abacre.com/afr/ In the batch replace you may enter as many words or lines as you need to and it will change in all files in a folder without opening the files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.