Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Batch string substitution
Name: RAJ Date: February 2, 2005 at 13:12:12 Pacific OS: Win 2K CPU/Ram: Pentium4 / 512M
Comment:
I have a question with regards to variable substring substitution in an NT batch program.
For example, the following piece of code works as expected and replaces 'ab' with 'xy'.
::Edit and replace the character string 'ab' with 'xy' SET v_test=123abcd Set v_replacement=xy SET v_result=%v_test:ab=xy% ECHO %v_result% = 123xycd
How can I perform the substitution, when the replacement string is a variable instead of the contant string 'xy' i.e. I want to replace 'ab' with the contents of the variable %v_replacement%, instead of the hardcoded value 'xy' ?
Name: dtech10 Date: February 2, 2005 at 14:00:25 Pacific
Reply:
The command prompt as to be executed with ENABLEDELAYEDEXPANSION for the code below to work. 1, Right click the "Command Prompt" as add the "/v" in the Target box as below. and run the code.
Summary: Hi all you great masters of batch scripting! Let’s suppose I have one file named ‘output_utm.txt’ with 5 tokens in it which first two I need to elaborate (in fact, a quite complex elaboration pe...
Summary: Hi, Please help me on this. As part of a batch script, I need to replace (or substitute) a particular character in a string variable with another character. For example: set vara=hellohow r u need to ...
Summary: please, does anyone can help me with this batch: why it is failing the string substitution which is supposed to do as assigned to the variable "new"; in the output instead of the "new" string there is...