Computing.Net > Forums > Programming > extracting a part of string in Batch File

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.

extracting a part of string in Batch File

Reply to Message Icon

Name: dharamshiv
Date: May 10, 2009 at 13:58:08 Pacific
OS: Windows XP
Subcategory: Batch
Comment:

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




Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: May 10, 2009 at 22:02:18 Pacific
Reply:

@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


0

Response Number 2
Name: dharamshiv
Date: May 10, 2009 at 22:59:50 Pacific
Reply:

Hi Mechanix2Go,

Problem solved.
Thanks a lot.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: extracting a part of string in Batch File

Comparison of strings in batch file www.computing.net/answers/programming/comparison-of-strings-in-batch-file/15556.html

Batch File to find files www.computing.net/answers/programming/batch-file-to-find-files/17076.html

nt batch to replace string in srt file www.computing.net/answers/programming/nt-batch-to-replace-string-in-srt-file/19260.html