DADiSP Worksheet Functions > Function Categories > File Manipulation > FILESTRREP

 

FILESTRREP

Purpose:

Replaces a pattern string with a new pattern in one or more files.

Syntax:

FILESTRREP("filespec", "patstr", "repstr", recurse)

 

"filespec"

-

A string. A list of files to process, can include wildcard characters such as * and ?.

"patstr"

-

A string. The original pattern to search for.

"repstr"

-

A string. The replacement pattern.

recurse

-

Optional. An integer, recursively process files in sub-directories.

 

 

0:

do not recurse (default)

1:

recurse

Returns:

An integer, the number of files in which the replacement occurred.

Example:

filestrrep("\temp\*.txt", "January", "April")

 

Returns the count of the number of files in the "\temp" folder with extension ".txt" where the text "January" was replaced with the text "April".

Remarks:

The pattern and replacement strings are case sensitive.

 

If the pattern is not found in a file, the file remains unchanged.

 

See STRREPLACE to replace a pattern in a string.

See Also:

STRCAT

STRCMP

STREXTRACT

STRFIND

STRGET

STRMATCH

STRREPLACE

STRSORT

UNIX2DOS