不好意思,上面的代码贴错了- pushd %~dp0
- @echo off
- setlocal enabledelayedexpansion
-
- rem 查询根目录
- set /a count = 0
- set /a file1size = 0
-
- for /f %%i in ('dir /b /a-d') do (
- set /a count=count+1
- set /a file1size=file1size+%%~zi
- )
- echo 根目录
- echo %cd% 文件数:!count!个、文件大小和:!file1size!个字节
-
- rem 查询子目录
- set /a counter = 0
- set /a file2size = 0
-
- for /f %%i in ('dir r* /b/a') do (
- if exist %%a (
- set /a counter=counter+1
- set /a file2size = file2size+%%~za
- )
- )
- )
- echo 子目录
- echo %cd% 文件数:!counter!个、文件大小和:!file2size!个字节
-
- popd
- pause
复制代码 这个才是正确的 |