find and remove character in a bat file

May 2, 2009 at 18:18:05
Specs: Windows XP and Vista
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.


See More: find and remove character in a bat file

Report •

May 2, 2009 at 18:24:57
Nevermind, I figured it out

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

Report •
Related Solutions

Ask Question