|
Answer» Hi Folks!
I'm hoping this will have a simple solution.... I need a command that I can put in a batch file that will simply return the NUMBER files contained in a given directory. If I execute the "dir" command, the entire contents of the directory are RETURNED, including the file count and directory count (parent and current). All I want to see is the file count.
Can someone help me? Thanks in advance!
RichardDepends on how complicated you want to get in filtering output. The absolute simplest way is to pipe the dir output to the find command: dir | find "file(s)" This will display a single line that has the file count and number of BYTES used.That's EXACTLY what I was looking for! THANK you VERY much!!!!
Copy and paste this into Notepad:
@dir %1 | find "file(s)"
Save the file as count.bat in the c:\windows\command directory. Make sure the saved file does not have a .txt extension
When you are in DOS, in any directory, type count at the command line. It will give the above result for the current directory. If you want a count for a different directory, include the path in the command line.
count c:\ would give the result for the root directory. count c:\windows\system would give the result for windows\system.
|