[英]Set Directory listing as variable in batch file dir /B /A-D /S | find /c /v “~~~”
I am trying to write a bat file that counts all files in a directory and subdirectoires and sets a variable based on the output. 我正在尝试编写一个bat文件,该文件对目录和子目录中的所有文件进行计数,并根据输出设置变量。 Something like this:
像这样:
set /a FILECOUNT=dir c:\Dir1 /B /A-D /S | find /c /v "~~~"
echo %FILECOUNT%
The output of the dir is only a number, I can't figure out how to get that number into my variable. dir的输出只是一个数字,我无法弄清楚如何将该数字放入变量中。
for /f %%a in ('dir c:\Dir1 /B /A-D /S | find /c /v "~~~"') do set FileCount=%%a
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.