Search/Replace in multiple files

<?xml version="1.0"?>
<xsharper xmlns="">
    <versionInfo value="Search/Replace in multiple text files" Version="" Copyright="(C) 2009 DeltaX Inc." />
    <usage options="ifNoArguments default autoSuffix" />
    <param name="filter" required="true" value="file filter to search, for example *.txt" />
    <param name="search" required="true" value="what to search" />
    <param name="replace" value="with what to replace" default="" />
    <param />
    <param synonyms="d" switch="directory" default="." value="Directory where to start searching" />
    <param synonyms="r" switch="recursive" count="none" default="0" unspecified="-1" value="Scan all subdirectories" />
    <param synonyms="i" switch="ignoreCase" count="none" default="0" unspecified="-1" value="Ignore case" />
    <param switch="regex" count="single" unspecified="" description="regex-options" value="Treat search and replace as regular expressions." />
    <param synonyms="e" switch="encoding" value="Force encoding (utf-8/ascii/utf-16/windows-1252/...)" />
    <param synonyms="w" switch="write" count="none" value="Write files. If this switch is not specified, script will just print filenames." />
    <param synonyms="nb" switch="nobackup" count="none" value="Do not create backup copies (w/o this key file.ext~ are created for all modified files)." />
    <setAttr actionId="dir" recursive="${recursive}" />
    <setAttr actionId="r" options="multiline|${regex|=null}" />
    <set count="0" />
    <dir id="dir" from="${directory}" filter="${filter}">
        <readText from="${from}" encoding="${encoding|=null}" outTo="original" />
        <if isSet="regex">
                <regex id="r" pattern="${search}" replace="${replace}" options="multiline" value="${original}" outTo="changed" />
                <set name="changed" value="${=$original.Replace($search,$replace)}" />
        <if isNotZero="${=string.Compare($original,$changed)}">
            <if isSet="write">
                    <if isNotSet="nobackup">
                        <copy from="${from}" to="${from}.~" overwrite="always" />
                    <writeText to="${from}" encoding="${encoding|=null}" value="${changed}" />
    <!-- Example of using if/else construction in C# -->
     if (c.IsSet("write"))
        <print outTo="$info">${count} files were changed.</print>
        <print outTo="$info">${count} files found.</print>