|
用下面这样也可以 其实首空格可以不用考虑 只需要考虑尾部含空格的情况
- !BAT
- debug 0
- set tmp=
- set newpath=
- setlocal
- set tmp=/a c b .iso
- set length=%@retval%
- set n=-1
- :start
- if not "%tmp:~-1%"==" " && goto :check_blank
- set tmp=%tmp:~,-1%
- set length=%@retval%
- goto :start
- :check_blank
- if "%n%"=="%length%" && goto :end
- set /a n=%n% + 1 > nul
- call if "%^tmp:~%%n%%,1%"==" " || goto :check_next
- call set newpath=%newpath%\%^tmp:~%%n%%,1%
- goto :check_blank
- :check_next
- call set newpath=%newpath%%%^tmp:~%%n%%,1%
- goto :check_blank
- :end
- endlocal && set newpath=%newpath%
- exit
复制代码 |
评分
-
查看全部评分
|