Search and Replace String in variable

July 13, 2009 at 06:02:31
Specs: Windows XP
How do I search name for '.doc' and replace it with '.txt' to get a value of word.txt?

set name=word.doc
find '.doc' in %name% and set it to txt
echo %txt%, should be word.txt


See More: Search and Replace String in variable

Report •


#1
July 13, 2009 at 07:42:53
A bit confused, but in short:

====================
@echo off & setLocal EnableDelayedExpansion

set str=abcdef
echo !str!
set str=!str:def=xyz!
echo !str!


=====================================
If at first you don't succeed, you're about average.

M2


Report •

#2
July 13, 2009 at 22:02:45
Fabulous - worked perfectly. Thanks

Report •

Related Solutions


Ask Question