&kfilereplace; is an utility to search and replace strings.
</para>
</abstract>
<keywordset>
<keyword>KDE</keyword>
<keyword>KFileReplace</keyword>
<keyword>replace</keyword>
<keyword>search</keyword>
<keyword>string</keyword>
</keywordset>
</bookinfo>
<chapter id="introduction">
<title>Introduction</title>
<para>&kfilereplace; is an application used to search and replace a list of strings in a file tree. The strings may be literal or Qt-like regular expressions. There are also other options to tune your search.
</para>
</chapter>
<chapter id="using-kfilereplace">
<title>Using &kfilereplace;</title>
<para>
<screenshot>
<screeninfo>&kfilereplace; in its standalone incarnation</screeninfo>
<para>This button shows a <link linkend="kfilereplace-the-project-dialog">session dialog</link> in which you can set several basic options; if &kfilereplace; run as standalone application you should click this button as first step.</para>
<para>This button loads a <link linkend="kfilereplace-the-kfr-file">string list</link> saved in a xml file with a <literal role="extension">kfr</literal> extension.</para>
<para>The <guilabel>Results</guilabel> view shows the name of the files that contain the strings you have to retrieve (and replace), their path, their size, the number of strings found and the user id of the files. This view also provides the exact position of each match. You can also open a file by clicking with the &RMB; on an list entry that contains line and column position.</para>
</sect1>
<sect1 id="kfilereplace-the-strings-view">
<title>The String List</title>
<para>This is the <guilabel>Strings</guilabel> view:
<para>The <guilabel>Strings</guilabel> view visualizes the list of strings you want search/replace. Please note that in search mode the <guilabel>Results</guilabel> view and the <guilabel>Strings</guilabel> view have a different layout.</para>
<para>The <guilabel>New Session</guilabel> dialog is used to setup the basic parameters needed by &kfilereplace; to work. It consists of two tabs, <guilabel>General</guilabel> and <guilabel>Advanced</guilabel>.
<para>When you want to begin a new session the first step is to click on the <link linkend="kfilereplace-the-toolbar"><guiicon>New Session</guiicon> button</link>. Then you must enter the base path and a sequence of shell-like wildcards to use as filter.</para>
<para>Then you could set some useful options, like searching in all the subfolders, doing a case-sensitive search, enabling commands and/or regular expressions<footnote id="performancewarning"><para>Please note that regular expressions and commands could slow down the speed performances.</para></footnote>, doing a backup copy of each file before replacing.</para>
<para>If you want to start searching, you can put a string in the search box and press <guibutton>Search Now</guibutton>, otherwise leave the search box empty and press <guibutton>Search Later</guibutton>.</para>
<para>The <guilabel>Advanced</guilabel> tab allows you to set up some useful options to restrict the search to a subset of your target file tree. If you want to run &kfilereplace; only over files that have a size in the range of 10KB - 100KB, then you could use the size options. There is also a date option that restricts the search in a temporal range, and a last option that allows you to only search for files owned (or not owned) by a particular user (this may be more useful to the system administrators).</para>
<para>This dialog contains options that are in the toolbar and extra options that may come in handy in some situations. You can invoke it selecting <menuchoice><guimenu>Settings</guimenu><guimenuitem>Configure KFileReplace...</guimenuitem></menuchoice> in the main menu.
<phrase>The Advanced tab of the Options window</phrase>
</textobject>
</mediaobject>
</screenshot>
<segmentedlist>
<segtitle>Do not show files if no strings are found or replaced</segtitle>
<segtitle>When searching, stop on first string found</segtitle>
<segtitle>Follow symbolic links</segtitle>
<segtitle>Ignore hidden files and directories</segtitle>
<seglistitem>
<seg>shows only the files that match some of your strings. This will speed up the search.</seg>
<seg>&kfilereplace; will stop when it finds a matching string, and will continue to search for other strings or, if you search for only one string, it will continue with the next file.</seg>
<seg>if a file is a link to another one, then search in the real file.</seg>
<seg>if hidden files or folders are encountered, ignore them.</seg>
<para>This dialog is used to insert and edit a list of strings. You just have to insert either a search-only or a search-and-replace list, and then with the two mini-editors you will introduce your text. The arrow buttons allow you to add pairs of strings or delete them. When you finish, click <guibutton>OK</guibutton>.</para>
</sect1>
</chapter>
<chapter id="kfilereplace-features">
<title>&kfilereplace; features</title>
<para>This chapter provides informations about some useful capabilities of &kfilereplace;.</para>
<sect1 id="kfilereplace-the-kfr-file">
<title>How to save your string list</title>
<para>When you want to reuse a list of strings you can save it in a <literal role="extension">xml</literal> file. To do this select from the menubar <menuchoice><guimenu>Search/Replace</guimenu><guisubmenu>Strings</guisubmenu><guimenuitem>Save Strings List to File</guimenuitem></menuchoice>. When you save a list, a simple <literal role="extension">xml</literal> file with extension <literal role="extension">kfr</literal> is created. To load a <literal role="extension">kfr</literal> file select from menubar <menuchoice><guimenu>Search/Replace</guimenu><guisubmenu>Strings</guisubmenu><guimenuitem>Load Strings List from File</guimenuitem></menuchoice>. The actual file looks like this:</para>
<para>If you are using a previous format, you can update by hand your file by simply modifying it according to the above scheme. Alternatively, you can load the file written in the old format and save it again with &kfilereplace; in the way explained before.</para>
</sect1>
<sect1 id="kfilereplace-the-report-file">
<title>How to Create a Simple Report</title>
<para>You can create a report by choosing <menuchoice><guimenu>Search/Replace</guimenu><guisubmenu>Results</guisubmenu><guimenuitem>Create Report File</guimenuitem></menuchoice> from the main menu. A report is a folder containing an <literal role="extension">xml</literal> and a <literal role="extension">css</literal> file. Reports may be useful to maintain a simple log of your operations.
If you want search for every string that starts with <quote>x</quote>, <quote>ht</quote> or <quote>u</quote> and ends with <quote>ml</quote>, you can write a regular expression like this: <userinput>(x|ht|u)ml</userinput>. Insert this expression in the search editor, click <guibutton>OK</guibutton>, and enable regular expressions by toggling the <link linkend="kfilereplace-the-toolbar"><guibutton>Regular Expression</guibutton> button</link>. Please note that using regular expressions lets you to make very complicated searches, but the cost could be a performance degradation. Regular expression can be very tricky, and it is often the case that <quote>if you want to solve a problem with a regular expression, you have two problems</quote>.</para>
</sect1>
<sect1 id="kfilereplace-backup-file">
<title>How to Protect Original Files</title>
<para>If you do not want to lose your original files, you can make a copy of them before replacing the strings. After inserting your strings, and before starting the replacement process, you have just to toggle the <link linkend="kfilereplace-the-toolbar"><guiicon>Backup</guiicon> button</link>. If you want to customize the extension of the backup files open the <link linkend="kfilereplace-the-options-dialog"><guilabel>Options</guilabel> dialog</link>.
</para>
</sect1>
<sect1 id="kfilereplace-open-file">
<title>How to Open a File</title>
<para>If you want to open a file that matches some of your strings, you have to select a line in the result view and click on it with the &RMB;. A context menu will appear from which you can open the file. If you use &kfilereplace; embedded in &quantaplus;, you can open the file directly in it at the specified line and column.</para>
</sect1>
<sect1 id="kfilereplace-commands">
<title>Commands</title>
<para>Suppose you want replace the phrase <quote>Alice's adventures in Wonderland</quote> with the <ulink url="http://www.textlibrary.com/download/alice-wo.txt">entire file that contains Carroll's novel</ulink>. Probably you don't want to do this by hand, what you need is a command that will do it for you. Click the <link linkend="kfilereplace-the-toolbar"><guiicon>Add</guiicon></link> button, select <guilabel>Search and Replace Mode</guilabel> and insert the following strings: <userinput>Alice's adventure in Wonderland</userinput> in the search mini-editor and the string <userinput>[$loadfile:<replaceable>/the-path-to-my-folder/my-folder/my-file</replaceable>$]</userinput> in the replacement mini-editor. Click <guibutton>OK</guibutton>. When you come back to the &kfilereplace; main window, toggle the <link linkend="kfilereplace-the-toolbar">Command action</link> button that enables the commands, and start the replacement process. There are also other commands, see <xref linkend="available-commands"/> for a list of all of them.</para>
</sect1>
</chapter>
<chapter id="credits">
<title>Credits and License</title>
<para>&kfilereplace;. Program copyright 1999 by François Dupoux <email>dupoux@dupoux.com</email>, 2003 Andras Mantia <email>amantia@kde.org</email>, 2004 Emiliano Gulmini <email>emi_barbarossa@yahoo.it</email>
</para>
<variablelist>
<title>The &kfilereplace; authors and maintainers:</title>
&kfilereplace; is currently part of &tdewebdev; package, so, in order to install it, you have to get a copy of &tdewebdev;. Note that if you are using a &kde; installation provided by your OS vendor, probably you already have &tdewebdev; installed; in this case, you can use &kfilereplace; either by opening &quantaplus; Web editor, or by calling it directly (unless you have an old &kde; version). Else you can download the &tdewebdev; package from the Internet: please refer to <ulink url="http://tdewebdev.org">&tdewebdev; home site</ulink> for more information.
<para>In order to use the command <link linkend="available-commands">[$mathexp:<replaceable>some_math_expression</replaceable>$]</link> you should install the &bc; mathematical utility (version 1.06 or newer) written by Philip A. Nelson (<email>philnelson@acm.org</email>).</para>