extracting a part of string in Batch File

May 10, 2009 at 13:58:08
Specs: Windows XP
Batch

Hi I am not able to extract a part of a string. I need Help

i am using this expression
set var1=%cd:~-%length%%
where length is 10 but this is not working

but when i use the following expression its working fine.
set var1=%cd~-10%

i just want to use variable name at place of 10

Thanks
shiv



See More: extracting a part of string in Batch File

Report •


#1
May 10, 2009 at 22:02:18
@echo off & setLocal EnableDelayedExpansion

set /a N=10
set var=!CD:~-%N%!

echo !var!


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

M2


Report •

#2
May 10, 2009 at 22:59:50
Hi Mechanix2Go,

Problem solved.
Thanks a lot.


Report •

Related Solutions


Ask Question