China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-11 22:05
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » 请问如何统计某个目录下的文件数量? 翻译为:How to count the number of files in a certain directory? View 1,678 Replies 7
Original Poster Posted 2007-07-01 11:43 ·  中国 福建 厦门 电信
初级用户
Credits 32
Posts 13
Joined 2006-03-27 23:17
20-year member
UID 52913
Status Offline
For example, if I want to count how many *.exe files are in a directory, what command should I use and how to count it?
Floor 2 Posted 2007-07-01 12:02 ·  中国 天津 电信
银牌会员
★★★
Credits 1,928
Posts 931
Joined 2007-01-06 11:46
19-year member
UID 75624
Gender Male
Status Offline
Are there any subdirectories under the directory?
Floor 3 Posted 2007-07-01 12:16 ·  中国 天津 电信
银牌会员
★★★
Credits 1,928
Posts 931
Joined 2007-01-06 11:46
19-year member
UID 75624
Gender Male
Status Offline
```@echo off
for /f %%i in ('dir /s c:\windows\*.exe^|findstr "个文件"') do set a=%%i
echo There are %a% files in total
pause
```
Floor 4 Posted 2007-07-01 16:19 ·  中国 福建 厦门 电信
初级用户
Credits 32
Posts 13
Joined 2006-03-27 23:17
20-year member
UID 52913
Status Offline
Great, there are really many experts here! Thank you
Floor 5 Posted 2007-07-01 19:10 ·  中国 福建 厦门 电信
初级用户
Credits 32
Posts 13
Joined 2006-03-27 23:17
20-year member
UID 52913
Status Offline
What does adding a ^ after dir *.* mean?
Floor 6 Posted 2007-07-01 19:58 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline
Originally posted by toy at 2007-7-1 19:10:
What does adding a ^ after dir *.* mean?

Temporarily cancel the special function of the pipe symbol | after ^.
Floor 7 Posted 2007-07-02 00:33 ·  中国 河北 唐山 联通
银牌会员
★★★
Credits 1,148
Posts 514
Joined 2007-06-01 12:51
19-year member
UID 89959
Gender Male
From 河北
Status Offline
Batch processing is mostly consistent with C language. Unfortunately, I only know a little bit, so I can't help you.
Floor 8 Posted 2010-08-20 22:58 ·  中国 湖南 怀化 电信
新手上路
Credits 12
Posts 9
Joined 2008-02-01 15:59
18-year member
UID 109967
Gender Male
Status Offline
The test didn't succeed!?
Forum Jump: