I have the following thing in my bat file. say
set path=c:\temp\test
so basically i want to have an output which would give me the result as c:\temp\
i didnt find any indexof equivalent in bat command.
Thanks.
Background:
>set fullname=c:\mypath\oldfile
>set changedname=%fullname:oldfile=newfile%
>echo %changedname%
c:\mypath\newfile
Applied to problem:
> set fullname=c:\mypath\oldfile
> set pathonly=%fullname:oldfile=%
> echo %pathonly%
c:\mypath\
A question that really makes me wish 4DOS still existed. However, I found something that might help in alt.msdos.batch.nt
. The manual page for set
seems to contain most of the same information. (command help set
)
set test=123456789
rem extract chars 0-5 from the variable test
set test=%test:~0,5%
echo %test%
(Note: tested on Windows XP SP3)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With