Computing.Net > Forums > Programming > find and remove character in a bat 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.

find and remove character in a bat file

Reply to Message Icon

Name: scrfix
Date: May 2, 2009 at 18:18:05 Pacific
OS: Windows XP and Vista
Subcategory: Batch
Comment:

I am trying just to return the drive letter from the %systemdrive% variable. Since the variable returns C: for the most part I would like to remove the : and just have the C for the bat file. I would like this to work on both Vista and XP from a batch file. Any ideas how I can accomplish this?

I know I can use findstr /C:: to find the character however I am not sure how to remove the character from there.

Any help would be greatly appreciated.

Wayne



Sponsored Link
Ads by Google

Response Number 1
Name: scrfix
Date: May 2, 2009 at 18:24:57 Pacific
Reply:

Nevermind, I figured it out

@echo off
set drivelt=%systemdrive%
echo %drivelt:~0,-1%
@pause


0
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: find and remove character in a bat file

find and replace string in a file www.computing.net/answers/programming/find-and-replace-string-in-a-file/19987.html

Find and Replace text in Batch File www.computing.net/answers/programming/find-and-replace-text-in-batch-file/12413.html

How to delete a file in a bat www.computing.net/answers/programming/how-to-delete-a-file-in-a-bat/18452.html