Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a few thousand files that I need to search and replace. Is there a software that can open a directory of files, scan those files and then search and replace? I'm aware that you can script something like this. However, I have no interest and prefer to use something that is already made.

share|improve this question
1  
which OS do you use? –  akira Oct 23 '11 at 5:37
add comment

3 Answers

up vote 4 down vote accepted

If you're using Linux you can pipe the results of a find command into sed to perform the replace.

find . -name '*.txt' -print0 | xargs -0 sed -i 's/searchpattern/replacepattern/'

This will find every file in your current directory and below (. is your current directory) and replace instances of searchpattern with replacepattern.

share|improve this answer
add comment

I often work on Windows and various flavours of Unix, and for replacing text I use sfk. For example, to replace "foo" with "bar" in all .txt files in folder logfiles and all subdirs, type the following:

sfk replace -pattern /foo/bar/ -dir logfiles -file .txt

It will do a simulation run. Add the -yes switch to actually replace the text.

share|improve this answer
    
Are you associated with this project at all or it's developer? If so please disclose this per the FAQ or this might be considered SPAM. –  KronoS Jul 18 '12 at 23:02
    
no, I just use the program often for my daily work. –  pgarcia Jul 19 '12 at 2:24
add comment

If you're using Windows, you could try to use NotePad++.
There's a tab in its Replace window that scans for files in a folder (you can choose an extension to filter) and do search/replace automatically.

Just note that doing thousands of files can take a very long time. This depends on the specifications of your computer. Just ensure you have a backup of the files you are going to find and replace in case Notepad ++ crashes and you lose data.

share|improve this answer
    
Strange. I contributed to the second part of the answer and it says Diago did it. –  Sam Oct 23 '11 at 11:11
1  
@Sam: looking at the edits history, I saw you put your contribute right after mine, without blank lines. Diago fixed it. Thanks to everybody who made my answer better, thanks a lot!! –  Marco Oct 23 '11 at 11:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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