Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

batch get current directory without drive letter

How can I get the current working directory and get the path without the drive letter for instance:

C:\testing\test\test
I would like to get in a variable
testing\test\test 

How can I trim the drive letter? I can get the full path using

set fullPath = %CD%

I can't use the %~d0 notation as it gives me the path of my script versus the actual working directory I'm in

like image 957
user391986 Avatar asked Jan 17 '23 01:01

user391986


2 Answers

Check out the following link:

set fullPath=%cd:~3%
echo %fullPath%

http://blogs.msdn.com/b/oldnewthing/archive/2005/01/28/362565.aspx

like image 174
Habib Avatar answered Jan 31 '23 09:01

Habib


%cd:~3%

eg:

C:\testing\test\test>echo %cd:~3%
testing\test\test

C:\testing\test\test>

DOS string manipulations, here:

http://www.dostips.com/DtTipsStringManipulation.php#Snippets.MidString

like image 25
jon Avatar answered Jan 31 '23 09:01

jon