EmEditor Home - EmEditor Help - EmEditor Macro Reference - Editor Object

ReplaceInFiles Method

Replaces text in multiple files.

[JavaScript]

editor.ReplaceInFiles( strFind, strReplace, strPath, nFlags, nEncoding, strFilesToIgnore, strBackupPath );

[VBScript]

editor.ReplaceInFiles strFind, strReplace, strPath, nFlags, nEncoding, strFilesToIgnore, strBackupPath

Parameters

strFind

Specifies a string to search for.

strReplace

Specifies a string to replace with.

strPath

Specifies a path to search from. It can include wild cards such as * and ?.

nFlags

Specifies a combination of the following values.

eeFindRecursive Searches in subfolders of the specified path.
eeFindReplaceCase Matches cases.
eeFindReplaceEscSeq Uses escape sequences. Cannot combine with eeFindReplaceRegExp.
eeFindReplaceIgnoreFiles Ignores the files or folders specified by strFilesToIgnore.
eeFindReplaceOnlyWord Searches only words.
eeFindReplaceRegExp Uses a regular expression. Cannot combine with eeFindReplaceEscSeq.
eeFindSaveHistory Saves the searched string for repeated search.
eeOpenDetectAll Detects all encodings.
eeOpenDetectCharset Detects HTML/XML Charset.
eeOpenDetectUnicode Detects Unicode signature (BOM).
eeOpenDetectUTF8 Detects UTF-8.
eeReplaceBackup Saves the backups. Cannot combine with eeReplaceKeepOpen.
eeReplaceKeepOpen Keeps the modified files open. Cannot combine with eeReplaceBackup.

nEncoding

Selects from the Encoding Constants, or specify any code page used in the Windows Operating System.

strFilesToIgnore

If nFlags  includes eeFindReplaceIgnoreFiles, specifies the file or folder names to ignore. It can include wild cards such as * and ?. To specify multiple files, use semicolons (;) to separate them.

strBackupPath

Specifies the backup folder if nFlags  specifies eeReplaceBackup.

Remarks

This action cannot be undone unless nFlags  specifies eeReplaceKeepOpen. It is recommended to specify eeReplaceBackup as nFlags  and saves backups. If the same file name exists in the backup folder, the new backup will overwrite the old file.

Version

Supported on EmEditor Professional Version 4.02 or later.

Copyright 2003-2015 by Emurasoft, Inc.