{smcl}
{* *! version 2.0  2011-07-19}{...}
{cmd:help renfiles}
{hline}

{title:Title}

{p2colset 5 19 21 2}{...}
{bf:renfiles} {hline 2} Renaming matched files by replacing specified sign/substring with another sign/substring.
{p2colreset}{...}


{title:Syntax}

{p 4 16 2}
{opt renfiles} [{cmd:,} {opt folder}({it:string}) {opt match}({it:string}) {opt insign}({it:string}) {opt outsign}({it:string}) {opt erase}]



{title:Description}

{pstd}
{cmd:renfiles} 
is a program that helps to rename files in a quite generally applicable fashion - 
changes applied to all matched filenames in a stated directory. 
The simplest syntax is purely based on defaults. All options are optional. 

{pstd}
If the sign
to-be-replaced is a dot, the last dot is not changed (keeping file-suffix).



{title:Options}

{pstd}
{opt folder}({it:string}) Defines the directory from within where to look for files. 
The default directory is the current working directory (cwd; '.').

{pstd}
{opt match}({it:string}) Defines the matching criterion used in order to select files 
from the selected directory {bf:folder}. The default is all files in the directory ('*').

{pstd}
{opt insign}({it:string}) The sign to be replaced when applying the used criterion {bf:match} 
with respect to the files in the directory {bf:folder}. Is case-sensitive. The default is the dot sign ('.').

{pstd}
{opt outsign}({it:string}) The sign to be replacing (the to-be-replaced sign {bf:insign}) when 
applying the used criterion {bf:match} with respect to the files in the directory {bf:folder}. 
To remove the sign {bf:insign}, i.e. replacing it with an empty space, use string {it:null}.
The default is the underscore sign ('_').

{pstd}
{opt erase} An indicator for whether, or not, the original matched (but unchanged) files should be removed from
the directory. 


{title:Examples}

    {hline}
{pstd} 1. Remove dots from all files in current working directory and replace them with underscores. {p_end}
{phang2}{cmd:. renfiles}{p_end}

    {hline}
{pstd} 2. Remove dots from all files with prefix {it:name} located in cwd-subdirectory {it:data} and replace them with dashes. {p_end}
{phang2}{cmd:. renfiles , folder(".\data") match("name*") outsign("-")}{p_end}

    {hline}
{pstd} 3. Same as Example 2, but in this case all matched, original, files are also to be erased. {p_end}
{phang2}{cmd:. renfiles , folder(".\data") match("name*") outsign("-") erase}{p_end}

    {hline}

{pstd} 4. Remove all occurrences of {it:file} and replace them with abbreviation {it:f} in all files with filenames including string-part {it:proj3} located in cwd-subdirectory {it:results}.{p_end}
{phang2}{cmd:. renfiles , folder(".\results") match("*proj3*") insign("file") outsign("f")}{p_end}

    {hline}

{pstd} 5. Same as Example 4, but in this case all Denmark-specific letters ('å', 'æ' and 'ø') are removed in a sequential manner; original/temporary files are erased.{p_end}
{phang2}{cmd:. renfiles , folder(".\results") match("*proj3*") insign("å") outsign("aa") erase}{p_end}
{phang2}{cmd:. renfiles , folder(".\results") match("*proj3*") insign("æ") outsign("ae") erase}{p_end}
{phang2}{cmd:. renfiles , folder(".\results") match("*proj3*") insign("ø") outsign("oe") erase}{p_end}

    {hline}

{pstd} 6. Same as Example 4, but in this case all present empty spaces, within matched filenames, are removed (replaced with null space; see note above).{p_end}
{phang2}{cmd:. renfiles , folder(".\results") match("*proj3*") insign(" ") outsign("null")}{p_end}

    {hline}


{title:Author}

{pstd} Lars Ängquist {break}
       la@ipm.regionh.dk {break}
       lars.angquist@telia.com


{title:Also see}

{psee}
{space 2}Help:  [help pages on] {help extended_fcn}, {help dir}, {help erase}
{p_end}
