Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am having the string like that

set s="c:\test\test1\test.exe"

i need echo the value of "c:\\test\test\test" only
how to do that in batch file
Posted

 
Share this answer
 
The solution barneyman gave is spot on, here is a direct code solution but with the variable without the quotations...

SQL
@echo off
SET var=c:\test\test1\test.exe
@echo %var:~0,-4%
pause


Basically what it does is
1) Switch of the echo
2) Creates the variable string
3) echo the variable string from position 0 to the back character -4 places...so it removes the .exe extension
4) pause to witness the result
 
Share this answer
 
v2
Use ~p to expand to path only:
echo %~ps
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900