|
Answer» Hi all, I had a simple batch issue that I'm not SURE how to resolve. I need to know how many files are in a directory, from within a batch file. How can I get/extract that #?
Many thanks, John put this batch into your path then execute the batch in each directory
dir . >junk type junk
look at the last line or two
you will need to SUBTRACT 2 as the . and .. files are INCLUDED. A little easier.
echo off echo %1 contains echo. dir%1 | find "file(s)" dir%1 | find "dir(s)"
Save it as a .bat file. I named mine howmany.bat and put it in the windows directory. At a DOS prompt, typing howmany will show the files and directories for the current directory. Typing howmany "\program files" would give the info for program files. Howmany \ would give the info for the root directory. You can use any complete directory path as the PARAMETER but should enclose in " ". Can also be USED from start/run by including the path parameter.
|