Counting the number of files in a directory, command line style


I needed to count the number of files in a directory on a Windows 2003 server.  Here’s the command that can easily be scripted:

dir/b/a-d c:\directory | find /v /c “::”

You can also specify a file share instead of a directory name:

dir/b/a-d \\server\share | find /v /c “::”

If you want to count the number of files in a directory and all subdirectories, the command is:

dir/s/b/a-d \c:\directory | find /v /c “::”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: