中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-12 15:40
47,811 topics / 349,897 posts / today 0 new / 48,256 members
DOS批处理 & 脚本技术(批处理室) » Question about dir, asking for advice!
Printable Version  986 / 4
Floor1 KenDeng Posted 2010-04-12 14:18
新手上路 Posts 8 Credits 8 From 四川南充
Experts,
I have a question:

I have many folders in d:\test\, and I want to use a P to view their sizes (the folders).

Thanks!
Floor2 Hanyeguxing Posted 2010-04-12 14:50
银牌会员 Posts 897 Credits 1,039 From 在地狱中仰望天堂
Floor3 gool123456 Posted 2010-04-12 20:25
初级用户 Posts 76 Credits 89
I'll add one too!!

@echo off
setlocal enabledelayedexpansion
set pt=d:\test
echo :
for /f "tokens=*" %%c in ('dir %pt% /ad /b /s') do (
for /f "tokens=3,4 delims= " %%i in ('dir "%%c"^|findstr "个文件"') do (
echo -------------------
echo."%%c" : %%i %%j
set "zer=%%i"
set "zer=!zer:,=!"
set /a num=!num!+!zer!
)
)
for /f "tokens=3,4 delims= " %%i in ('dir "%pt%"^|findstr "个文件"') do (
echo -------------------
echo."%pt%" : %%i %%j
set "zer=%%i"
set "zer=!zer:,=!"
set /a num=!num!+!zer!
)
echo.
echo :
echo %num% bytes
pause>nul
goto :eof
Floor4 gool123456 Posted 2010-04-12 20:46
初级用户 Posts 76 Credits 89
Modified it a bit, now you can calculate the size by dragging in the folder:
@echo off
mode con cols=100 lines=20
setlocal enabledelayedexpansion
set /p pt=Drag in the folder?:
set "pt=%pt:"=%"
echo :
for /f "tokens=*" %%c in ('dir "%pt%" /ad /b /s') do (
for /f "tokens=3,4 delims= " %%i in ('dir "%%c"^|findstr "个文件"') do (
echo -------------------
echo."%%c" : %%i %%j
set "zer=%%i"
set "zer=!zer:,=!"
set /a num=!num!+!zer!
)
)
for /f "tokens=3,4 delims= " %%i in ('dir "%pt%"^|findstr "个文件"') do (
echo -------------------
echo."%pt%" : %%i %%j
set "zer=%%i"
set "zer=!zer:,=!"
set /a num=!num!+!zer!
)
echo.
echo :
echo %num% bytes
pause>nul
goto :eof
Floor5 KenDeng Posted 2010-04-17 10:22
新手上路 Posts 8 Credits 8 From 四川南充
I don't really understand it, still studying it!!!。


Thanks first!!
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023