给你一段演示代码:- @echo off
- set /a num1=0,num2=0
- set "str=%cd%"
-
- :loop
- set /a num1+=1
- if "%str:~0,1%"=="\" set /a num2+=1
- set "str=%str:~1%"
- if defined str goto loop
-
- echo 当前路径为:"%cd:"=%"
- echo 共计 %num1% 个字符,其中字符"\"有 %num2% 个
- for %%i in ("%cd%") do echo 当前目录名为:"%%~nxi"
- pause
复制代码
|