简体   繁体   中英

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

%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

Check out the following link:

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM