ModifyFile |
Top Previous Next |
The ModifyFile command allows you to replace specific text in a specified text file with alternative text, and optionally output the modified text to a new file.
Command Syntax
ModifyFile:[SourceFileName],[TargetFileName]
The colon after the command is compulsory. The comma between parameters is compulsory if you provide a second parameter, otherwise it can be ignored. Any additional spaces or characters will cause an error to be thrown. The command itself is not case sensitive, but parameters may be depending on the operating system and locale.
Parameters:
SourceFileName: The fully qualified path and file name identifying the file to update. TargetFileName: The fully qualified path and file name to which the updated file should be saved
The SourceFileName parameter is compulsory, the TargetFileName parameter optional. If the TargetFileName parameter is not provided, the source file will be overwritten once modified. The parameters must be surrounded by quotation marks if one or more spaces are included in the path and file name. It is good practice to include the quotation marks in any case, so that it reduces the risk of error when writing scripts.
Examples:
Single file substitution to a different file:
ModifyFile:"C:\Test Text.txt","C:\Test Text (updated).txt"
Single file substitution overwriting the existing file:
ModifyFile:"C:\Test Text.txt"
See Also: Subs RegexReplace |