<para>&tdefilereplace; is an application used to search and replace a list of strings in a file tree. The strings may be literal or TQt-like regular expressions. There are also other options to tune your search.
<para>This button shows a <link linkend="tdefilereplace-the-project-dialog">session dialog</link> in which you can set several basic options; if &tdefilereplace; run as standalone application you should click this button as first step.</para>
<para>This button loads a <link linkend="tdefilereplace-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 that match the search criterias, their path, their size, the number of strings found, the user and group of the files owner. This view also provides the exact position of each match. The columns can be sorted either ascending or descending by clicking on the column headers.</para>
<para>You can open a file by clicking with the &RMB; on a list entry, by single/double clicking (depending on your mouse settings) on an entry or alternatively by selecting an item and pressing Enter.</para>
<para>You can inspect the file properties using <guilabel>Properties</guilabel> from the &RMB; menu. You can also delete a file from the file system using <guilabel>Delete</guilabel> or simply remove the item from the results list using the <guilabel>Remove Entry</guilabel> command.</para>
<para>The <guilabel>Strings</guilabel> view visualizes the list of strings you want to search for and eventually replace with. Please note that the layout of both the <guilabel>Results</guilabel> view and the <guilabel>Strings</guilabel> view is different if you are only searching or if you are searching and replacing.</para>
<para>The <guilabel>Customize Search/Replace Session</guilabel> dialog is used to setup the basic parameters needed by &tdefilereplace; 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="tdefilereplace-the-toolbar"><guiicon>Customize Search/Replace 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 including limiting the max depth of searching, 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. You can set restrictions on the size, access date and ownership of the files to be searched for.</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 TDEFileReplace...</guimenuitem></menuchoice> in the main menu.
<para>These options have been presented in the <link linkend="tdefilereplace-the-toolbar">Toolbar</link> section. In addition to those, you can specify the default file encoding to use and the suffix for backing up files.
<seg>shows only the files that match some of your strings. This will speed up the search.</seg>
<seg>&tdefilereplace; 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="tdefilereplace-features">
<title>&tdefilereplace; features</title>
<para>This chapter provides informations about some useful capabilities of &tdefilereplace;.</para>
<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>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.
<para>You can also save and load the results list contents to/from file using the <menuchoice><guimenu>Search/Replace</guimenu><guisubmenu>Results</guisubmenu><guimenuitem>Save Results List to file...</guimenuitem></menuchoice> and <menuchoice><guimenu>Search/Replace</guimenu><guisubmenu>Results</guisubmenu><guimenuitem>Load Results List from file...</guimenuitem></menuchoice>. This is very useful if you are searching over a lot of files and for many strings, so you can save and resume your checks across multiple days.</para>
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="tdefilereplace-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="tdefilereplace-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="tdefilereplace-the-toolbar"><guiicon>Backup</guiicon> button</link>. If you want to customize the extension of the backup files open the <link linkend="tdefilereplace-the-options-dialog"><guilabel>Options</guilabel> dialog</link>.
<para>You can open a file by clicking with the &RMB; on a list entry, by single/double clicking (depending on your mouse settings) on an entry or alternatively by selecting an item and pressing Enter. If you use &tdefilereplace; embedded in &quantaplus;, you can open the file directly in it at the specified line and column.</para>
<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="tdefilereplace-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 &tdefilereplace; main window, toggle the <link linkend="tdefilereplace-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>&tdefilereplace;. 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 &tdefilereplace; authors and maintainers:</title>
<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>