Windows Command Line Find and replace – Made easy with FART.exe

Here is a great little application that does a find and replace on a particular file, file type or file contents, then replaces it with a string of your choice. It can look in sub directories as well.
The small app is called FART, yes that’s right FART – Find And Replace Text!

Usage: FART [options] [–] [,…] [find_string] [replace_string]

  • -h, –help Show this help message (ignores other options)
  • -q, –quiet Suppress output to stdio / stderr
  • -V, –verbose Show more information
  • -r, –recursive Process sub-folders recursively
  • -c, –count Only show filenames, match counts and totals
  • -i, –ignore-case Case insensitive text comparison
  • -v, –invert Print lines NOT containing the find string
  • -n, –line-number Print line number before each line (1-based)
  • -w, –word Match whole word (uses C syntax, like grep)
  • -f, –filename Find (and replace) filename instead of contents
  • -B, –binary Also search (and replace) in binary files (CAUTION)
  • -C, –c-style Allow C-style extended characters (xFFtnr\ etc.)
  • –cvs Skip cvs dirs; execute “cvs edit” before changing files
  • –svn Skip svn dirs
  • –remove Remove all occurences of the find_string
  • -a, –adapt Adapt the case of replace_string to found string
  • -b, –backup Make a backup of each changed file
  • -p, –preview Do not change the files but print the changes

Example 1 (replace text, preview only)

fart -c -r -i -p *.txt original_text new_text

This will look for all .txt files in a sub directory, locate the original_text string within the .txt file and change it to new_text. The -p switch means it won’t actually change anything because this is a preview, showing you how many strings it found within each .txt file.

Example 2 (replace text)

fart -c -r -i *.txt original_text new_text

Same as above except it will do the actual replacement.

Example 3 (remove text)

fart -r -i --remove *.txt "remove this text"

Rather than replacing one term for another this will remove the specified term.

NOTE: Use quotes around text if it contains spaces, tabs, etc.

Download FART from SourceForge.


windows fart.exe
fart find and replace
notepad find/replace text command line
fart “command line” download
fart.exe find and replace
find and replace fart
replace file command line windows
“find and replace” fart examples
detailed manual fart find replace
find and replace command line executable

23 thoughts on “Windows Command Line Find and replace – Made easy with FART.exe

  1. great tool

    any idea of how i can go about replacing a text string that contains a colon?

    c:windowsfart.exe –c-style "S:misc_videosSkate*.wvx" G:_Media_Center <Ref href=G:_Media_Center


  2. Mark, try using the backslash () as an escape character immediately before the colon. And (or?) put both text strings in quotes. Example: c:windowsfart.exe –c-style "S:misc_videosSkate*.wvx" "G:_Media_Center"

  3. dellfalconer, I routinely use it on files that are several GB in size. In fact, I'm watching it run on a file that's about 12GB right now. I use it daily on several files so I know it works just fine.

    While you probably aren't running out of disk space I wanted to point out that fart.exe will create a temporary file, _fart.~, in the same directory as the file you are operating on. This temp file will grow to about the same size as the original file, therefore you have to make sure to have at least as much free space on your volume as the file on which you are finding and removing text.

  4. I have plenty of disk space. What I tried to convert was %% to x0Dx0A. I had to enter %% as %%%% to get it to work on the small file, but it didn't convert anything on the large file. Anyway I solved my problem another way. My file transfer now outputs 0D0A directly, so I have no need to convert any more.

  5. I had code I needed to replace in Windows that looked like this:

    div id ..

    And needed to remove both lines. Obviously I can't do a find-replace-all for /div> in an HTML file because everything would break. Needed to figure out how to deal with new lines. After a lot of head banging I figured out how to go.

    – Find and replace "div id .. rn"
    This is essentially the same as pressing backspace from behind the /div>.

    Now the text is:
    div id .. /div> rn"
    Now you can remove "div id .. /div>"

    Hope that helps.

  6. Just trying a simple example and can't get it to work – Please Help ?

    fart test.txt oldstring newstring

    => returns "Replaced 0 occurence(s) in 0 file(s)?

  7. is there a way to replace text within two static pieces of text kinda like
    oldstring= "C:UsersrandomtextDocuments"
    newstring= "C:UsersnewtextDocuments"
    please any help would be amazing.

  8. Hi
    I am struggling with fart.exe to make modification to lines that includes quotation marks.

    All commas embraced by quotation marks must be replaced with semicolon embraced by quotation marks.
    Like this:
    Before: ","
    After : ";"
    However standalone commas must not be touched.

    Before: "Resistor","SMD RES 0,1W 0R"
    After : "Resistor";"SMD RES 0,1W 0R"

    Is this possible?

    Have tried with:
    C:Fart.exe -c -r -i Test.txt "," ";"
    but it is not working. It also replaces the comma not embraced by quotation marks:
    "Resistor";"SMD RES 0;1W 0R"

  9. This program has trouble with files that have commas in their names. IE this will not work: fart.exe "some file (with, commas).txt" [TEXT] [NEWTEXT]

    However you can do this and it will work: for /f "tokens=* delims= " %a in ('dir /b /a-d "some*.txt"') do fart.exe "*.txt" [TEXT] [NEWTEXT]

  10. In my file the accepted pattern for " is ,",. Whenever there is a " and its followed by some letter or preceded by some letter or any other symbol other than , I need to correct it. Any suggestions on how I can do it with Fart.exe is greatly appreciated. Thanks!

  11. Is there any idea to find the multiple words and replace the words with it's respective changes in same file using single fart command?

    FILE NAME:test.txt
    CONTENTS: This is a Pencil.It is used to write a content.

    I want to change this "Pencil to Eraser" and "write to erase" using single fart command.

  12. You could replace the phrase, "Pencil.It is used to write" with "Eraser.It is used to erase." Note: your example didn't have a space between Pencil and the period so this example doesn't either.
    Like this: fart.exe test.txt "Pencil.It is used to write" "Eraser.It is used to erase"

Leave a Reply to Anonymous Cancel reply

Your email address will not be published. Required fields are marked *