|
我这里只给你一个 样例,应该可以更简化的。自己研究吧,有时间我们在研究。
@echo off
set p0=C:\Abcde\Bcdef\Cdefg\Defgh\Efghijk
echo p0=%p0%
set p1=%p0:~0,-1%
:loop1
if %p1:~-1%==\ goto 1
set "p1=%p1:~0,-1%"
goto loop1
:1
echo p1=%p1:~0,-1%
set p2=%p1:~0,-1%
:loop2
if %p2:~-1%==\ goto 2
set "p2=%p2:~0,-1%"
goto loop2
:2
echo p2=%p2:~0,-1%
set p3=%p2:~0,-1%
:loop3
if %p3:~-1%==\ goto 3
set "p3=%p3:~0,-1%"
goto loop3
:3
echo p3=%p3:~0,-1% |
|