Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm looking to find / replace in alot of files and was wondering if anybody could recommend some good tools for Windows. I'd prefer them to be free.

Thanks

share|improve this question

closed as off-topic by Falcon Momot, Jenny D, Bryan, Scott Pack, mdpc Jul 20 '13 at 6:01

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions seeking product, service, or learning material recommendations are off-topic because they tend to become obsolete quickly. Instead, describe your situation and the specific problem you're trying to solve." – Falcon Momot, Jenny D, Bryan, Scott Pack, mdpc
If this question can be reworded to fit the rules in the help center, please edit the question.

add comment

5 Answers 5

up vote 8 down vote accepted

This is what I use:

for GUI grepWin: link text

for superfast commandline: gsar.exe from link text

share|improve this answer
add comment

Install Cygwin, its free and gives a linux-like scriptable environment in Windows.
Do lookup the manual pages for commands I describe here (man find for example).

List files in a directory (folder) with,

find . -type f  
## Note: you can also select files here (see the man page)

Use that to search in multiple files like this,

grep -Hn pattern $(find . -type f)

Use it to replace across files like this.
Create a script file (say) replace-in-files.sh.
Write the following in the file,

#!/bin/sh
# Sample script: replace-in-files.sh
for f in $(<find . -type f);
do
    sed 's/pattern/replacement/g' $f > tmpFile.txt
    mv tmpFile.txt $f;
done;
rm -f tmpFile.txt

Here,
tmpFile.txt should be some temporary name (not already existing in the directory).
And, pattern is the regex you want to change with replacement.
Execute chmod a+x replace-in-files.sh and the file becomes an executable that you can fire from a Cygwin terminal with ./replace-in-files.sh

You can build up for there for many other requirements.
To lookup manual pages for commands like sed, find, grep you can also google "manual sed" etc.

The Advanced Bash Scripting guide at the Linux Documentation Project site is a good reference and most of the concepts work under Cygwin. Also has Awk, sed, briefs at the end.

share|improve this answer
add comment

Whilst probably not as fast as the above options - Notepad++ has a good find/replace with RegEx support.

share|improve this answer
add comment

I would go with Cygwin. If this is not desirable, on http://unxutils.sourceforge.net/ you can find a bunch of standalone GNU utilities like sed, grep and find ported to Windows.

share|improve this answer
add comment

I've been using Text WorkBench for a while now and think it's fantastic. It's got lots of useful features including batch replace plans, regular expressions, include/exclude file extensions, editing files inside the application, etc.

Not free though... Think it costs about $40, but is easily worth it given the amount of time it saves. I'm not affiliated with the company in anyway, just a happy customer.

share|improve this answer
    
-1 Shareware, Richard asked for freeware –  cept0 Jun 3 '13 at 10:25
    
@cept0 Not quite. The exact words in the question are "I'd prefer them to be free" (emphasis mine). –  Mun Jun 3 '13 at 20:38
add comment

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