ReplaceStrFromFile
Go Up to Local GetIt Packages Actions Data Index
Replaces some text in the content of the file. In other words, this command allows you to modify a file that is part of the package with a string replace operation, so that you can inject information in the file (for example, a course code file or include file) programmatically.
Parameters
- Parameter 1: String. File path. Macros are allowed.
- Parameter 2: String. Old string to replace if parameter 4 is set to "False".
Note: If parameter 4 is set to
True
, you must enter a regular expression pattern.- Parameter 3: String. A new string to replace. Macros are allowed if parameter 5 is set to
True
. - Parameter 4: Boolean. Optional. Specifies if you want to use a regular expression or not. The default value is
False
. - Parameter 5: Boolean. Optional. Specifies if the new string to replace (Parameter 3) must be expanded before in case of using macros (for instance,
$(BDS)
). The default value isFalse
. - Parameter 6: Boolean. Optional. If the value is
True
, it skips the action without failing if the file does not exist. The default value isFalse
.
Examples
- Example 1:
ReplaceStrFromFile("c:\test.txt", "Old string", "New string", False);
- Example 2:
ReplaceStrFromFile("c:\test.dproj", "\<ProjectVersion\>(.+?)\<\/ProjectVersion\>", "<ProjectVersion>16.0</ProjectVersion>", True);
- Example 3: (Since BigBen or CatalogVersion = 5)
ReplaceStrFromFile("c:\test.txt", "_RADSTUDIOPATH_", "$(BDS)", False, True);
- Example 4: (Since BigBen or CatalogVersion = 5)
ReplaceStrFromFile("c:\test.txt", "_RADSTUDIOPATH_", "$(BDS)", False, True, True);