用批处理文件计算文件夹和子文件夹 [英] count folders and subfolders with batch file

查看:92
本文介绍了用批处理文件计算文件夹和子文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找创建一个批处理文件,当给定路径时,它将计算其中的所有文件夹和子文件夹.到目前为止,我只能收集路径第1层内的文件夹数量.然后,我将其通过管道传输到文本文件.

I am looking to create a batch file that when given a pathway, it will count all the folders and sub folders within it. So far I am only able to gather the number of folders within the 1st level of the pathway. I will then pipe it to a text file.

这是我到目前为止所拥有的:

Here's what I have so far:

for /f %%a in ('dir /b /ad %folder%^|find /c /v "" ') do set count=%%a
echo %count% folder(s^)>> !output!

我快要得到想要的东西了吗?我星期需要什么?

Am I close to getting what I want? What do I need to tweek?

谢谢!

推荐答案

添加/s以包括所有子文件夹:

Add /s to include all subfolders:

for /f %%a in ('dir /b /s /ad %folder%^|find /c /v "" ') do set count=%%a
echo %count% folder(s^)>> !output!

这篇关于用批处理文件计算文件夹和子文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆